Skip to content

fix: trigger failover on read-only connection errors in strict-writer mode#673

Open
sudosubin wants to merge 1 commit into
aws:mainfrom
sudosubin:fix/failover-readonly-trigger
Open

fix: trigger failover on read-only connection errors in strict-writer mode#673
sudosubin wants to merge 1 commit into
aws:mainfrom
sudosubin:fix/failover-readonly-trigger

Conversation

@sudosubin

@sudosubin sudosubin commented Jul 21, 2026

Copy link
Copy Markdown

Summary

Trigger failover on read-only connection errors in strict-writer mode, matching the JDBC and Python wrappers.

Description

After an Aurora writer failover, a pooled connection may still point at the former writer, now demoted to a reader. Writes on it return a read-only error (PostgreSQL SQLSTATE 25006, MySQL errno 1290/1836) rather than a network error. Since shouldErrorTriggerClientSwitch only checks isNetworkError, failover is never triggered and the connection stays pinned to the old writer. The JDBC and Python wrappers already treat this as a failover trigger in strict-writer mode.

This adds isReadOnlyConnectionError to ErrorHandler (PG: SQLSTATE 25006; MySQL: errno 1290/1836), delegated through PluginService like isNetworkError, and makes Failover2Plugin/FailoverPlugin trigger failover on it in strict-writer mode only (reader-or-writer mode is unchanged). Unit tests included.

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 July 21, 2026 16:57
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