Fix task_instance_history downgrade failing under the PyMySQL driver - #71258
Open
1fanwang wants to merge 1 commit into
Open
Fix task_instance_history downgrade failing under the PyMySQL driver#712581fanwang wants to merge 1 commit into
1fanwang wants to merge 1 commit into
Conversation
The MySQL branch of this downgrade passed two statements to a single op.execute(). PyMySQL does not enable CLIENT.MULTI_STATEMENTS, so it rejects the script with a syntax error and the downgrade cannot run. mysqlclient enables multi-statements, which is why the problem is invisible to anyone using that driver. Signed-off-by: 1fanwang <1fannnw@gmail.com>
1fanwang
force-pushed
the
mysql-0060-multistatement-downgrade
branch
from
August 6, 2026 20:22
8490e3d to
ee3ec1c
Compare
1fanwang
marked this pull request as ready for review
August 6, 2026 20:25
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.
The MySQL branch of this downgrade passes two statements to a single
op.execute():PyMySQL does not enable
CLIENT.MULTI_STATEMENTS, so it rejects the script with a syntax error and the downgrade cannot run. mysqlclient does enable it, which is why the problem is invisible to anyone on that driver, including CI:scripts/ci/docker-compose/backend-mysql.ymluses a baremysql://URL, which SQLAlchemy resolves tomysqldb.Splitting into two
op.execute()calls fixes it.op.execute()reusesop.get_bind(), so@row_numberis still visible to theUPDATE.Same class of bug as PR #70235, which fixes the multi-statement SQL in
0017_2_9_2. I found this one while looking at that PR. The two do not overlap.Testing Done
MySQL 8.4, the migration's own SQL against both drivers, before and after.
Raw logs
Table seeded with
try_idout of order (30, 10, 20) so the renumbering is observable:The fix produces identical numbering on both drivers, confirming the session variable survives across the two calls and the
ORDER BY try_idsequencing is unchanged.