mysqltopo: use the block-mysql driver - #22
Conversation
strata links github.com/block/mysql — Block's fork of go-sql-driver/mysql — for capabilities upstream does not carry. That fork is moving from a `replace` directive to its own module path (block/mysql#3), because `replace` is not inherited across module boundaries and so cannot reach consumers of a library. Once the path differs, a binary linking both packages gets two distinct `*mysql.MySQLError` types, and `errors.As` across that boundary silently returns false. convertError here depends on exactly that assertion to map 1062 to NodeExists and 1213/1205 to Timeout, and strata's own test helpers assert on the errors this package returns — so mysqltopo and strata must agree on which package the type comes from. Scope is deliberately mysqltopo only: it is Block-added, so editing it costs nothing when merging upstream vitess. The remaining go-sql-driver imports live in upstream-owned endtoend tests, which keep using upstream — the module stays in go.mod and both can coexist. The dependency is pinned to the block/mysql PR branch and must be re-pointed at its master commit before this merges. Verified: go/vt/topo/mysqltopo tests pass against MySQL 8.0.44.
|
🤖 Adversarial correctness review — The mechanical part is complete and I checked it rather than counting on the diff being uniform: all five The check that matters most for a rename like this is what happens to a site you miss, and here it fails loudly. I probed the package's test binary directly: Nothing links upstream into this package, so a stray
1 — the comment picks a global premise where a local one is both true and sufficient (low)// Block's fork of go-sql-driver/mysql, registered as "block-mysql". strata
// links the fork for capabilities upstream does not carry; using it here
// too keeps one driver — and so one *mysql.MySQLError type — in the binary,
// which is what convertError below depends on.
"github.com/block/mysql"Adding a comment here is right — an import whose path doesn't match the package name it binds deserves one. Two things about this particular justification. It isn't true of this repo. Eight test files still import upstream, and Production binaries do link only the fork, which is the useful half of the claim — but "one driver in the binary" as stated is a property no one is maintaining, and And it isn't what 2 — the other comment about the same type wasn't updated (low)// Handle MySQL-specific errors. go-sql-driver returns *mysql.MySQLError,
// which carries the server error number directly; ...
var driverErr *mysql.MySQLErrorThis is the comment attached to the assertion that the new comment at :54 exists to protect, and it still attributes the type to Same category, not worth its own row: Verified — the pin, the TLS registry, and three attacks that dissolvedThe pseudo-version pin is real and current. ⭐ The TLS registry is fully on one side, which is the half-migration that would have failed most confusingly. Attack that dissolved: a Attack that dissolved: the unrelated Attack that dissolved: an aliasing mistake around the two Local: This review was generated by Claude Code (claude-opus-5). |
aparajon
left a comment
There was a problem hiding this comment.
🤖 Approving — the switch is complete (all five sql.Open sites, no non-test upstream import left in the repo), the pin resolves to block/mysql#3's merge commit on master, and the TLS registry is entirely on one side. Probed the package's test binary: it registers only block-mysql, so a missed call site fails loudly rather than binding upstream.
Two low findings in my review comment — both about the comments, not the code: the new import comment rests on a whole-binary premise this repo doesn't hold (eight test files still import upstream) when the local one is true and sufficient, and the comment on the *mysql.MySQLError assertion still credits go-sql-driver.
This stamp was left by Claude Code (claude-opus-5).
The import comment claimed one driver in the binary; eight end-to-end test files still import go-sql-driver, so that is false. The local invariant is both true and sufficient: every *sql.DB this package opens uses the driver whose *mysql.MySQLError convertError asserts on. Add a package const for the name and use it at all five sql.Open sites, so that invariant is one grep rather than five, and fix the convertError comment to credit block-mysql.
Part of the block/mysql#3 wave. Draft — the dependency is pinned to that PR's branch and must be re-pointed at a master commit before merging.
Why
strata links
github.com/block/mysql, Block's fork of go-sql-driver/mysql, for capabilities upstream doesn't carry (QueryResultContext,Warnings()). That fork is moving from areplacedirective to its own module path, becausereplaceisn't inherited across module boundaries and so can't reach consumers of a library built on it.Once the module path differs, a binary linking both packages has two distinct
*mysql.MySQLErrortypes, anderrors.Asacross that boundary returns false silently rather than failing loudly.That matters here specifically.
convertErrordepends on exactly that assertion:NodeExistsTimeoutAnd strata's own test helpers assert on errors this package returns. If mysqltopo stays on upstream while strata moves to the fork, those mappings quietly stop matching — the failure mode is a retry loop that never fires, not a compile error.
Scope
Deliberately mysqltopo only:
server.go,notification.go— import path andsql.Opendriver namemain_test.go,notification_test.go,server_error_test.go,server_resolve_test.gomysqltopo is Block-added, so editing it costs nothing when merging upstream vitess. The remaining
go-sql-driver/mysqlimports in this repo are all in upstream-owned files (go/test/endtoend/…,go/vt/vtgate/semantics/info_schema_gen_test.go); touching those would create permanent merge conflicts, so they keep using upstream. The module stays in go.mod and both coexist.Note the two files alias the import differently —
server.gotakes it as plainmysql,notification.goasmysqldriver, because theremysqlis vitess's owngo/mysql. AlsoRegisterTLSConfig("rds-topo", …)and thesql.Openit feeds have to move together, since the TLS registry is package-level state; both are inserver.go, so they did.Verification
go/vt/topo/mysqltopotests pass against MySQL 8.0.44.🤖 Generated with Claude Code