Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,20 @@ linters:
- bodyclose # unclosed HTTP response bodies
- usetesting # enforce t.Context() over context.Background() in tests
- unparam # unused/constant function parameters and results
- depguard # banned imports (see settings)
settings:
# SchemaBot links exactly one MySQL driver. The deny list is what keeps that
# true: nothing about a second one fails to compile, and the way it breaks
# is silent (see pkg/mysqlerr.Number), so the invariant needs an enforcer
# rather than a comment.
depguard:
rules:
main:
deny:
- pkg: github.com/go-sql-driver/mysql
desc: 'import github.com/block/mysql instead (registered as driver name "block-mysql"). Two MySQL drivers in one binary define two field-identical but distinct *mysql.MySQLError types, and errors.As against one returns false for the other, so a classifier keeps compiling and silently stops recognizing deadlocks. Read codes through pkg/mysqlerr.'
- pkg: github.com/go-mysql/hotswap-dsn-driver
desc: 'use mysqlconn.OpenReloadable, which reloads credentials per pool on block/mysql. That driver embeds upstream go-sql-driver/mysql and cannot be pointed at the fork.'
errcheck:
exclude-functions:
- (io.Closer).Close # bodyclose linter handles HTTP resp.Body; other Close() checked by closeandlog analyzer
Expand Down
9 changes: 3 additions & 6 deletions e2e/consumermodule/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ require (
github.com/aws/aws-sdk-go-v2/service/sts v1.43.3 // indirect
github.com/aws/smithy-go v1.27.7 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/block/mysql v0.0.0-20260906224346-ee0a93fe50d6 // indirect
github.com/block/pg-sprite v0.2.0 // indirect
github.com/block/spirit v0.16.1-0.20260903162727-fc5f1dfb0a40 // indirect
github.com/block/spirit v0.17.1-0.20260907005557-10804bbe247c // indirect
github.com/bradleyfalzon/ghinstallation/v2 v2.18.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand All @@ -48,8 +49,6 @@ require (
github.com/go-logr/logr v1.4.4 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-mysql-org/go-mysql v1.16.1-0.20260731133054-6f853f178dc3 // indirect
github.com/go-mysql/hotswap-dsn-driver v1.0.1 // indirect
github.com/go-sql-driver/mysql v1.10.0 // indirect
github.com/goccy/go-json v0.10.6 // indirect
github.com/gofri/go-github-ratelimit/v2 v2.0.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.2 // indirect
Expand Down Expand Up @@ -126,6 +125,4 @@ replace github.com/block/schemabot => ../..

// Mirror the parent module's replace directives; replaces do not propagate
// across module boundaries.
replace vitess.io/vitess => github.com/block/vitess v0.0.0-20260703150944-881ec2298245

replace github.com/pingcap/tidb/pkg/parser => github.com/block/tidb/pkg/parser v0.0.0-20260506200501-e528fd979fc8
replace vitess.io/vitess => github.com/block/vitess v0.0.0-20260907005807-88d15fda31ea
18 changes: 8 additions & 10 deletions e2e/consumermodule/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ github.com/aws/smithy-go v1.27.7 h1:Zgj5z4LfcDYoQIVk+n/yGdTkP/2y6ZT5vYxe0fp7bqE=
github.com/aws/smithy-go v1.27.7/go.mod h1:YE2RhdIuDbA5E5bTdciG9KrW3+TiEONeUWCqxX9i1Fc=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/block/mysql v0.0.0-20260906224346-ee0a93fe50d6 h1:GvubwsqXHanJkhBotCs4XdEmSnwzhHQe7DVGrn+NFok=
github.com/block/mysql v0.0.0-20260906224346-ee0a93fe50d6/go.mod h1:KEo73lbxXs9cFlq+x3Z35UqGg3MTxAPfjDOR/ob/iik=
github.com/block/pg-sprite v0.2.0 h1:H6w/MNJf1rc7XtdVEI0Sq63I2+MkiifPgkS3qfZ9Rz8=
github.com/block/pg-sprite v0.2.0/go.mod h1:vZxHdTMrCOPAYgswveB7PSjOaOuRgnDLGRw6WoOizRg=
github.com/block/spirit v0.16.1-0.20260903162727-fc5f1dfb0a40 h1:fEnxgrBNGJj4CtcYLfcQ2uVeqzTP9/9ZsUdKdP4Wb74=
github.com/block/spirit v0.16.1-0.20260903162727-fc5f1dfb0a40/go.mod h1:DmRuKoQODH6VReVLEsfMSgYPuVLUi051cx8ya1WylWM=
github.com/block/tidb/pkg/parser v0.0.0-20260506200501-e528fd979fc8 h1:+OfdTacrEyjlqcRUpBFX9uJ6ROBq6cUjwY4DClhnsdU=
github.com/block/tidb/pkg/parser v0.0.0-20260506200501-e528fd979fc8/go.mod h1:zDLDsfNBU5+L6T4J9/OgWAHc/WZvMUjbpgHqQ/t3yKo=
github.com/block/vitess v0.0.0-20260703150944-881ec2298245 h1:R7e7uAxl6WIZpeY957JDsrZtuihck6vm7QgRooI295U=
github.com/block/vitess v0.0.0-20260703150944-881ec2298245/go.mod h1:tOLnFt2ryuSGSYZ9NxLjsRhYrWxGBxz/z0zxrvuWYwE=
github.com/block/spirit v0.17.1-0.20260907005557-10804bbe247c h1:Gdd1vWs0UKLlvq84+4wMveyls7QkFqhQDpF21KR2cIA=
github.com/block/spirit v0.17.1-0.20260907005557-10804bbe247c/go.mod h1:Lg97/e4zr2X3AQXRUrDVAQZOVqFDZ09px503h4v/Yss=
github.com/block/vitess v0.0.0-20260907005807-88d15fda31ea h1:t9VROoN/aCzwwh7Ap90TLijZz3rZHZ6HUgWymC+yVS8=
github.com/block/vitess v0.0.0-20260907005807-88d15fda31ea/go.mod h1:193fxGVSfNHDStC08wSg/RzROVHmMh6XoT+QdfSoLjY=
github.com/bradleyfalzon/ghinstallation/v2 v2.18.0 h1:WPqnN6NS9XvYlOgZQAIseN7Z1uAiE+UxgDKlW7FvFuU=
github.com/bradleyfalzon/ghinstallation/v2 v2.18.0/go.mod h1:gpoSwwWc4biE49F7n+roCcpkEkZ1Qr9soZ2ESvMiouU=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
Expand Down Expand Up @@ -103,12 +103,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-mysql-org/go-mysql v1.16.1-0.20260731133054-6f853f178dc3 h1:ZLbHAIwCSSBhXzeM3IHrKYKlghU2WGQ4NETbld7iiyY=
github.com/go-mysql-org/go-mysql v1.16.1-0.20260731133054-6f853f178dc3/go.mod h1:VjBTZTTDKL8OMXUAhNbg3VHaVVq9HOXJEBLpAKBFIfE=
github.com/go-mysql/hotswap-dsn-driver v1.0.1 h1:Ssm8Gqk3DLkZSyEuFOh1g1ReKBwhLiuYF0Qy4eb0zvo=
github.com/go-mysql/hotswap-dsn-driver v1.0.1/go.mod h1:YjeTwHrsEcFpzJDfOFO95lPZACK/TVo/xtu4Qgi2uC8=
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
github.com/go-sql-driver/mysql v1.10.0 h1:Q+1LV8DkHJvSYAdR83XzuhDaTykuDx0l6fkXxoWCWfw=
github.com/go-sql-driver/mysql v1.10.0/go.mod h1:M+cqaI7+xxXGG9swrdeUIoPG3Y3KCkF0pZej+SK+nWk=
github.com/goccy/go-json v0.10.6 h1:p8HrPJzOakx/mn/bQtjgNjdTcN+/S6FcG2CTtQOrHVU=
github.com/goccy/go-json v0.10.6/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/gofri/go-github-ratelimit/v2 v2.0.2 h1:gS8wAS1jTmlWGdTjAM7KIpsLjwY1S0S/gKK5hthfSXM=
Expand Down Expand Up @@ -198,6 +194,8 @@ github.com/pingcap/errors v0.11.5-0.20260310054046-9c8b3586e4b2 h1:cLgCk5mwDG9lD
github.com/pingcap/errors v0.11.5-0.20260310054046-9c8b3586e4b2/go.mod h1:ktAJCA9lxrHHjVyVl2pKJFvzBnq2eZbb+CUOjBRPlXo=
github.com/pingcap/log v1.1.1-0.20260227082333-572e590d08f1 h1:A2bEfgSb7hLwR9mxDszgGKweF+xY9YoTDG+8RjdFjDE=
github.com/pingcap/log v1.1.1-0.20260227082333-572e590d08f1/go.mod h1:pxfz2oJfAuhwrb3/rcLqD//GS/5gRP4gD022iP3cEO0=
github.com/pingcap/tidb/pkg/parser v0.0.0-20260504140133-511dba1dbe17 h1:cfAVPis6GP6lxQgm1WGaNGi4rVXTB4KDvYf96LjqRCM=
github.com/pingcap/tidb/pkg/parser v0.0.0-20260504140133-511dba1dbe17/go.mod h1:zDLDsfNBU5+L6T4J9/OgWAHc/WZvMUjbpgHqQ/t3yKo=
github.com/planetscale/planetscale-go v0.155.0 h1:KYFRWFn9d5BeZc++4DF0wS+mlRQ4efrAy+6Zw/1kzXs=
github.com/planetscale/planetscale-go v0.155.0/go.mod h1:paQCI5SgquuoewvMQM7R+r1XJO868bdP6/ihGidYRM0=
github.com/planetscale/vtprotobuf v0.6.1-0.20250313105119-ba97887b0a25 h1:S1hI5JiKP7883xBzZAr1ydcxrKNSVNm7+3+JwjxZEsg=
Expand Down
6 changes: 3 additions & 3 deletions e2e/grpc/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ import (
"testing"
"time"

_ "github.com/block/mysql"
"github.com/block/schemabot/e2e/testutil"
"github.com/block/schemabot/pkg/state"
"github.com/block/spirit/pkg/utils"
_ "github.com/go-sql-driver/mysql"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand All @@ -61,7 +61,7 @@ func TestMain(m *testing.M) {
// Clean up SchemaBot's state tables to ensure fresh state
dsn := os.Getenv("E2E_SCHEMABOT_MYSQL_DSN")
if dsn != "" {
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
if err == nil {
rows, err := db.QueryContext(context.Background(), "SHOW TABLES")
if err == nil {
Expand All @@ -86,7 +86,7 @@ func TestMain(m *testing.M) {
if ternDSN == "" {
continue
}
db, err := sql.Open("mysql", ternDSN)
db, err := sql.Open("block-mysql", ternDSN)
if err != nil {
continue
}
Expand Down
12 changes: 6 additions & 6 deletions e2e/grpc/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (
"testing"
"time"

_ "github.com/block/mysql"
"github.com/block/schemabot/e2e/testutil"
"github.com/block/schemabot/pkg/state"
"github.com/block/spirit/pkg/utils"
_ "github.com/go-sql-driver/mysql"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -385,7 +385,7 @@ func grpcEnsureNoActiveChange(t *testing.T, database, env string) {
func grpcClearSchemabotState(t *testing.T) {
t.Helper()
dsn := grpcSchemabotMySQLDSN(t)
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
if err != nil {
t.Logf("warning: could not open schemabot db to clear state: %v", err)
return
Expand Down Expand Up @@ -418,7 +418,7 @@ func grpcClearTernStorage(t *testing.T, env string) {
testappDSN := grpcTernMySQLDSN(t, env)
ternDSN := strings.Replace(testappDSN, "/testapp", "/tern", 1)

db, err := sql.Open("mysql", ternDSN)
db, err := sql.Open("block-mysql", ternDSN)
if err != nil {
t.Logf("warning: could not open tern storage db (%s): %v", env, err)
return
Expand Down Expand Up @@ -452,15 +452,15 @@ func grpcClearTernStorage(t *testing.T, env string) {
func grpcCreateTestTable(t *testing.T, env, tableName, ddl string) {
t.Helper()
dsn := grpcTernMySQLDSN(t, env)
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
require.NoErrorf(t, err, "open tern mysql (%s)", env)

_, err = db.ExecContext(t.Context(), ddl)
require.NoErrorf(t, err, "create table %s on %s", tableName, env)
_ = db.Close()

t.Cleanup(func() {
db2, err := sql.Open("mysql", dsn)
db2, err := sql.Open("block-mysql", dsn)
if err != nil {
return
}
Expand All @@ -487,7 +487,7 @@ func grpcSeedRows(t *testing.T, env, tableName, columns, valueTemplate string, r
func grpcColumnExists(t *testing.T, env, tableName, columnName string) bool {
t.Helper()
dsn := grpcTernMySQLDSN(t, env)
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
require.NoErrorf(t, err, "open tern mysql (%s)", env)
defer utils.CloseAndLog(db)

Expand Down
12 changes: 6 additions & 6 deletions e2e/grpc/multideploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
"testing"
"time"

"github.com/block/mysql"
"github.com/block/schemabot/e2e/testutil"
"github.com/block/schemabot/pkg/state"
"github.com/block/schemabot/pkg/storage"
"github.com/block/spirit/pkg/utils"
"github.com/go-sql-driver/mysql"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -117,7 +117,7 @@ func multiDeployTernMySQLDSN(t *testing.T, deployment string) string {
func multiDeployCreateTestTable(t *testing.T, deployment, tableName, ddl string) {
t.Helper()
dsn := multiDeployTernMySQLDSN(t, deployment)
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
require.NoErrorf(t, err, "open tern mysql (%s)", deployment)
// Defer close immediately so the handle is reclaimed even if the create
// below fails a require.* assertion, and so close errors are logged.
Expand All @@ -126,7 +126,7 @@ func multiDeployCreateTestTable(t *testing.T, deployment, tableName, ddl string)
require.NoErrorf(t, err, "create table %s on %s", tableName, deployment)

t.Cleanup(func() {
db2, err := sql.Open("mysql", dsn)
db2, err := sql.Open("block-mysql", dsn)
if err != nil {
t.Logf("cleanup: open tern mysql (%s): %v", deployment, err)
return
Expand All @@ -153,7 +153,7 @@ func multiDeployCreateTestTable(t *testing.T, deployment, tableName, ddl string)
func multiDeploySeedRows(t *testing.T, deployment, tableName, columns, valueTemplate string, rowCount int) {
t.Helper()
dsn := multiDeployTernMySQLDSN(t, deployment)
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
require.NoErrorf(t, err, "open tern mysql (%s)", deployment)
defer utils.CloseAndLog(db)

Expand Down Expand Up @@ -228,7 +228,7 @@ func multiDeployTernStorageDSN(t *testing.T, deployment string) string {
func multiDeployClearTernStorage(t *testing.T, deployments ...string) {
t.Helper()
for _, d := range deployments {
db, err := sql.Open("mysql", multiDeployTernStorageDSN(t, d))
db, err := sql.Open("block-mysql", multiDeployTernStorageDSN(t, d))
require.NoErrorf(t, err, "cleanup: open tern storage db (%s)", d)
func() {
defer utils.CloseAndLog(db)
Expand Down Expand Up @@ -293,7 +293,7 @@ func multiDeployClearTernStorage(t *testing.T, deployments ...string) {
// applies row on the deployment's Tern.
func multiDeploySpendRecoveryBudget(t *testing.T, deployment string) {
t.Helper()
db, err := sql.Open("mysql", multiDeployTernStorageDSN(t, deployment))
db, err := sql.Open("block-mysql", multiDeployTernStorageDSN(t, deployment))
require.NoErrorf(t, err, "open tern storage db (%s)", deployment)
t.Cleanup(func() { utils.CloseAndLog(db) })
require.NoErrorf(t, db.PingContext(t.Context()), "ping tern storage db (%s)", deployment)
Expand Down
2 changes: 1 addition & 1 deletion e2e/k8s/dataplane_progress_ownership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func waitForPodRowCopyInFlight(t *testing.T, client ternv1.TernClient, applyID,
// indexExists reports whether the named index is present on the table.
func indexExists(t *testing.T, dsn, tableName, indexName string) bool {
t.Helper()
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
require.NoError(t, err)
defer utils.CloseAndLog(db)
require.NoError(t, db.PingContext(t.Context()))
Expand Down
4 changes: 2 additions & 2 deletions e2e/k8s/k8s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import (
"testing"
"time"

"github.com/go-sql-driver/mysql"
"github.com/block/mysql"

"github.com/block/schemabot/e2e/testutil"
"github.com/block/schemabot/pkg/apitypes"
Expand Down Expand Up @@ -523,7 +523,7 @@ func TestK8s_PlanApply_CreateTable(t *testing.T) {

// Register cleanup for the table the apply created
t.Cleanup(func() {
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
if err != nil {
return
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/local/apply_wait_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func applyTimeoutDiagnostics(applyID string) string {
if dsn == "" {
return "diagnostics: E2E_MYSQL_DSN not set"
}
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
if err != nil {
return fmt.Sprintf("diagnostics: open schemabot db: %v", err)
}
Expand Down
16 changes: 8 additions & 8 deletions e2e/local/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func newSchemaDir(t *testing.T) string {
func openTestappStaging(t *testing.T) *sql.DB {
t.Helper()
dsn := testappStagingDSN(t)
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
require.NoError(t, err, "open testapp staging db")
t.Cleanup(func() { utils.CloseAndLog(db) })
return db
Expand Down Expand Up @@ -298,7 +298,7 @@ func clearSchemaBotStateImpl() {
if schemabotDSN == "" {
return
}
db, err := sql.Open("mysql", schemabotDSN)
db, err := sql.Open("block-mysql", schemabotDSN)
if err != nil {
return
}
Expand Down Expand Up @@ -326,7 +326,7 @@ func clearSchemaBotStateImpl() {
func markApplyHeartbeatStale(t *testing.T, applyID string) {
t.Helper()

db, err := sql.Open("mysql", mysqlDSN(t))
db, err := sql.Open("block-mysql", mysqlDSN(t))
require.NoError(t, err)
defer utils.CloseAndLog(db)
require.NoError(t, db.PingContext(t.Context()))
Expand Down Expand Up @@ -398,15 +398,15 @@ func uniqueTableName(prefix string) string {
func createTestTable(t *testing.T, tableName, ddlStmt string) {
t.Helper()
dsn := testappStagingDSN(t)
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
require.NoError(t, err, "open db")
defer utils.CloseAndLog(db)

_, err = db.ExecContext(t.Context(), ddlStmt)
require.NoErrorf(t, err, "create table %s", tableName)

t.Cleanup(func() {
db2, err := sql.Open("mysql", dsn)
db2, err := sql.Open("block-mysql", dsn)
if err != nil {
return
}
Expand All @@ -426,7 +426,7 @@ func createTestTable(t *testing.T, tableName, ddlStmt string) {
func dropTestTable(t *testing.T, tableName string) {
t.Helper()
dsn := testappStagingDSN(t)
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
if err != nil {
return
}
Expand All @@ -440,7 +440,7 @@ func dropTestTable(t *testing.T, tableName string) {
func writeBaseFixtureSchemas(t *testing.T, schemaDir string) {
t.Helper()
dsn := testappStagingDSN(t)
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
if err != nil {
return
}
Expand All @@ -459,7 +459,7 @@ func writeBaseFixtureSchemas(t *testing.T, schemaDir string) {
func writeExistingTablesSchema(t *testing.T, schemaDir string) {
t.Helper()
dsn := testappStagingDSN(t)
db, err := sql.Open("mysql", dsn)
db, err := sql.Open("block-mysql", dsn)
if err != nil {
return
}
Expand Down
Loading
Loading