Skip to content

fix: detect read-only errors on wrapped mysql2 errors - #692

Open
sudosubin wants to merge 1 commit into
aws:mainfrom
sudosubin:fix/readonly-error-unwrap
Open

fix: detect read-only errors on wrapped mysql2 errors#692
sudosubin wants to merge 1 commit into
aws:mainfrom
sudosubin:fix/readonly-error-unwrap

Conversation

@sudosubin

@sudosubin sudosubin commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

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 an AwsWrapperError and keeps the original only as cause. MySQLErrorHandler read errno straight 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/lib has no such wrapper and hands the driver error to the plugins as-is.)

Fix: both handlers fall back to cause when 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.

@sudosubin
sudosubin requested a review from a team as a code owner August 20, 2026 02:52
@sudosubin
sudosubin force-pushed the fix/readonly-error-unwrap branch from 39fa4e6 to 4f57243 Compare August 20, 2026 02:55
@sudosubin
sudosubin force-pushed the fix/readonly-error-unwrap branch from 4f57243 to 8d8999d Compare August 26, 2026 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant