Conversation
jabbrwcky
force-pushed
the
fix/mysql-lock-wait-timeout
branch
2 times, most recently
from
July 23, 2026 12:58
a3c8bc3 to
b067c97
Compare
jabbrwcky
force-pushed
the
fix/mysql-lock-wait-timeout
branch
from
August 18, 2026 12:04
b067c97 to
fe39828
Compare
Contributor
Author
|
Superseded by #435 (same branch got wiped by a bad rebase, GitHub wouldn't let this PR reopen after recovery). |
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.
Description of your changes
Under a backlog of pending
ALTER USER/GRANT/DDL statements, MySQL/Percona can become unresponsive.go-sql-driver/mysqlcancels a context by closing the TCP socket without sendingKILL QUERY(intentional; all versions incl. latest v1.10.0). With MySQL's defaultlock_wait_timeoutof 1 year, a statement blocked on a metadata/ACL lock (e.g. behind a backup or long transaction) stays pending server-side even after the 60s reconcile deadline. Every retry adds another; account-management statements serialize on a single global ACL lock, so they pile up untilmax_connectionsis exhausted or the server wedges.This PR appends
lock_wait_timeout=30and dialtimeout=10sto the MySQL DSN so blocked statements fail fast server-side and release instead of accumulating. Applies to all MySQL controllers (User, Grant, Database; cluster + namespaced) via the shared client.Not covered / follow-ups:
KILL QUERYis the only remedy.sql.Open) — separate concern, see Provider should use connection pooling or single transaction to minimize load on database when reconciling #195.lock_wait_timeoutconfigurable viaProviderConfig.See
docs/mysql-driver-context-cancellation.mdfor the full analysis.Fixes #422
I have:
make reviewableto ensure this PR is ready for review.How has this code been tested
TestDSNParsesWithLockWaitTimeoutvalidating the DSN parses via the driver and carries the params.go build ./...,go vet, and full MySQL controller test suites pass.makeandmake reviewablepass.