fix: support pool_pre_ping in SQLAlchemy ORM MySQL dialect#1245
Merged
karenc-bq merged 1 commit intoJun 9, 2026
Merged
Conversation
Signed-off-by: sudosubin <sudosubin@gmail.com>
5b65ea7 to
e0541c8
Compare
karenc-bq
approved these changes
Jun 9, 2026
Contributor
|
Hi @sudosubin, thank you for contributing this fix, we will merge the changes now and post an update here once it has been released |
AhmadMasry
pushed a commit
to AhmadMasry/aws-advanced-python-wrapper
that referenced
this pull request
Jun 14, 2026
Signed-off-by: sudosubin <sudosubin@gmail.com>
AhmadMasry
added a commit
to AhmadMasry/aws-advanced-python-wrapper
that referenced
this pull request
Jun 14, 2026
Adopts AWS PR aws#1245 (do_ping), generalized from AWS sync-MySQL-only to all four wrapper dialects (MySQL+PG, sync+async). AwsWrapperConnection exposes no .ping(), so SA pool_pre_ping=True raised AttributeError. Each dialect now reaches the native driver connection via target_connection: - MySQL (sync/async): native ping(reconnect=False) (aiomysql bridged via await_only) - PG (sync/async): SELECT 1 (psycopg has no ping(); async bridged via await_) Returns False on failure -> SA _do_ping_w_event recycles the pooled conn. initialize() override (AWS mysql_orm_dialect) NOT needed: our _detect_charset override already handles the only wrapper-incompatible introspection path. Adds unit tests + [mypy-pymysql] ignore_missing_imports.
AhmadMasry
added a commit
to AhmadMasry/aws-advanced-python-wrapper
that referenced
this pull request
Jun 14, 2026
The branch already contains all of origin/main's commits (merged earlier in 66fbcd4 and adopted: SQLAlchemy ORM support, gdb RWS aws#1243, initial_connection default plugins aws#1242, do_ping aws#1245, etc.). The Co-Authored-By trailer rewrite re-hashed those merged-in main commits, so git's ancestry counter showed the branch as '11 behind main' even though the content is present (verified). Use -s ours to re-link origin/main as an ancestor without altering the validated, integration-tested tree -- a content merge would instead re-add files we intentionally dropped (mysql_orm_dialect.py replaced by our sqlalchemy_dialects/) and re-surface already-resolved conflicts.
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
Fixes
pool_pre_ping=Truefor the SQLAlchemy ORM MySQL dialect. SQLAlchemy passes the DBAPI connection todo_ping, which here is anAwsWrapperConnection. The inheriteddo_pingcallsdbapi_connection.ping(), butAwsWrapperConnectiondoes not exposeping(), so every pool checkout raised'AwsWrapperConnection' object has no attribute 'ping'.This overrides
do_pingto ping the wrapped driver connection (target_connection) instead. A dead connection raises a nativemysql.connectorerror, which SQLAlchemy cannot classify as a disconnect becauseimport_dbapireports the wrapper module as the DBAPI (its exception hierarchy is unrelated tomysql.connector's), sodo_pingcatches it and returnsFalse, letting the pool invalidate and reconnect.Unit tests are added for the live and dead connection paths.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.