fix: detect read-only errors on wrapped mysql2 errors - #692
Open
sudosubin wants to merge 1 commit into
Open
Conversation
sudosubin
force-pushed
the
fix/readonly-error-unwrap
branch
from
August 20, 2026 02:55
39fa4e6 to
4f57243
Compare
sudosubin
force-pushed
the
fix/readonly-error-unwrap
branch
from
August 26, 2026 23:01
4f57243 to
8d8999d
Compare
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.
Summary
Read read-only diagnostics off the wrapped error's
cause, so failover triggers on MySQL as well.Description
#673 added read-only connection error detection, but the MySQL side never fired.
Every mysql2 query goes through
ClientUtils.queryWithTimeout, which re-throws the driver error as anAwsWrapperErrorand keeps the original only ascause.MySQLErrorHandlerreaderrnostraight off the error it was handed, so it saw nothing on exactly the errors it exists to classify, and a demoted writer kept failing writes.(PostgreSQL was unaffected:
pg/libhas no such wrapper and hands the driver error to the plugins as-is.)Fix: both handlers fall back to
causewhen the error itself carries no diagnostics. That fallback is what makes MySQL work; on PostgreSQL it is there so the handler keeps working if that path is ever wrapped too.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.