Add MySQL topology server implementation#1
Merged
morgo merged 4 commits intorelease-23.0from Mar 12, 2026
Merged
Conversation
Adds a MySQL-based topology backend (mysqltopo) for Vitess, allowing MySQL to be used as the topology store instead of etcd/zk/consul. This is useful in environments where MySQL is already available and adding etcd/zk would increase operational complexity. New files: - go/vt/topo/mysqltopo/ - Full topo.Factory implementation using MySQL including server, elections, locking, watches, and notifications - Plugin registrations for vtctld, vtgate, vttablet, vtorc, topo2topo, and vtctldclient - Example scripts for local development with MySQL topo Modified files: - go/vt/topo/server.go - Reuse global connection for cells when the factory supports HasGlobalReadOnlyCell (shared DB backends) - go/flags/endtoend/*.txt - Register --topo-mysql-election-ttl and --topo-mysql-lock-ttl flags - .github/workflows/local_example.yml - Add mysql to CI matrix Based on vitess v23.0.3.
Signed-off-by: Morgan Tocker <mtocker@squareup.com>
…count Server.Close() unconditionally called releaseNotificationSystem, but the notification system is only acquired when Watch/WatchRecursive is called. This caused unbalanced refcounts: servers that never watched would decrement without incrementing, and servers that watched multiple times would increment multiple times but only decrement once. Fix by tracking whether each Server has acquired a reference via a hasNotificationSystem flag. getNotificationSystemForServer now only increments the refcount on the first call, and Close() only releases if a reference was actually acquired. Also fix TestMySQLTopo to close the topo.Server, which owns additional mysqltopo.Server instances for globalCell and local cell connections. Signed-off-by: Morgan Tocker <mtocker@squareup.com>
aparajon
reviewed
Mar 12, 2026
aparajon
reviewed
Mar 12, 2026
Collaborator
aparajon
left a comment
There was a problem hiding this comment.
🤖 These comments are Claude-generated (prompted by @armand-block for observability review).
Focused on logging gaps that would help debug production issues in downstream consumers that rely heavily on Watch, WatchRecursive, and CRUD operations.
Address review feedback from @aparajon focused on production debuggability: - Mark notification system as dead after exhausting retries and warn callers that watches will not receive updates - Add 5s timeout for slow consumers in notifyChange/notifyDeletion to prevent a single blocked watcher from stalling all binlog processing - Add lifecycle logging for watch/recursive watch registration and deregistration - Log server Close() with root/schema context, and warn on db.Close() errors instead of discarding them - Log notification system refcount transitions (increment/decrement/zero) - Log rollback errors in file.go CRUD operations instead of discarding (filtering out expected sql.ErrTxDone) - Log GTID extraction failures instead of silently swallowing them - Log topo change and deletion detection in checkForTopoDataChanges - Add Docker command example to mysql-up.sh error message
aparajon
approved these changes
Mar 12, 2026
aparajon
pushed a commit
that referenced
this pull request
Apr 21, 2026
* Add MySQL topology server implementation Adds a MySQL-based topology backend (mysqltopo) for Vitess, allowing MySQL to be used as the topology store instead of etcd/zk/consul. This is useful in environments where MySQL is already available and adding etcd/zk would increase operational complexity. New files: - go/vt/topo/mysqltopo/ - Full topo.Factory implementation using MySQL including server, elections, locking, watches, and notifications - Plugin registrations for vtctld, vtgate, vttablet, vtorc, topo2topo, and vtctldclient - Example scripts for local development with MySQL topo Modified files: - go/vt/topo/server.go - Reuse global connection for cells when the factory supports HasGlobalReadOnlyCell (shared DB backends) - go/flags/endtoend/*.txt - Register --topo-mysql-election-ttl and --topo-mysql-lock-ttl flags - .github/workflows/local_example.yml - Add mysql to CI matrix Based on vitess v23.0.3. * Fix ConnForCell to create cell-specific connections with correct root Signed-off-by: Morgan Tocker <mtocker@squareup.com> * mysqltopo: fix goroutine leak from unbalanced notification system refcount Server.Close() unconditionally called releaseNotificationSystem, but the notification system is only acquired when Watch/WatchRecursive is called. This caused unbalanced refcounts: servers that never watched would decrement without incrementing, and servers that watched multiple times would increment multiple times but only decrement once. Fix by tracking whether each Server has acquired a reference via a hasNotificationSystem flag. getNotificationSystemForServer now only increments the refcount on the first call, and Close() only releases if a reference was actually acquired. Also fix TestMySQLTopo to close the topo.Server, which owns additional mysqltopo.Server instances for globalCell and local cell connections. Signed-off-by: Morgan Tocker <mtocker@squareup.com> * Improve observability for mysqltopo Address review feedback from @aparajon focused on production debuggability: - Mark notification system as dead after exhausting retries and warn callers that watches will not receive updates - Add 5s timeout for slow consumers in notifyChange/notifyDeletion to prevent a single blocked watcher from stalling all binlog processing - Add lifecycle logging for watch/recursive watch registration and deregistration - Log server Close() with root/schema context, and warn on db.Close() errors instead of discarding them - Log notification system refcount transitions (increment/decrement/zero) - Log rollback errors in file.go CRUD operations instead of discarding (filtering out expected sql.ErrTxDone) - Log GTID extraction failures instead of silently swallowing them - Log topo change and deletion detection in checkForTopoDataChanges - Add Docker command example to mysql-up.sh error message --------- Signed-off-by: Morgan Tocker <mtocker@squareup.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's this?
A MySQL-based topology backend (
mysqltopo) for Vitess, so we can use MySQL (including RDS) as the topology store instead of etcd/zk/consul.This reduces operational complexity in environments where MySQL is already available.
How it works
topo.Factoryinterface backed by a MySQL databaseGET_LOCK()with configurable TTLsHasGlobalReadOnlyCellWhat's changed
New files (19):
go/vt/topo/mysqltopo/— full implementation: server, elections, locking, watches, notifications, testsexamples/common/scripts/mysql-up.sh— local dev setup scriptModified files (10):
go/vt/topo/server.go— reuse global connection for cells when factory supports itgo/cmd/vtctldclient/command/root.go— register mysqltopo importgo/flags/endtoend/*.txt— register--topo-mysql-election-ttland--topo-mysql-lock-ttlflagsBase
This is one commit on top of vitess
v23.0.3. Therelease-23.0branch points at the unmodified tag.Ported from the
mysql-topo-wipbranch — squashed into a single commit for review.