This repository was archived by the owner on Aug 19, 2025. It is now read-only.
Repetitive InterfaceError("(0, 'Not Connected')") Error in Nested Transactions.#528
Closed
ODD2 wants to merge 3 commits intoencode:masterfrom
ODD2:master
Closed
Repetitive InterfaceError("(0, 'Not Connected')") Error in Nested Transactions.#528ODD2 wants to merge 3 commits intoencode:masterfrom ODD2:master
ODD2 wants to merge 3 commits intoencode:masterfrom
ODD2:master
Conversation
…uery' exception occuredwhile starting a transaciton in nested transactions.
Contributor
|
Perhaps resolved by #546 ? |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Dear Authors,
I've been working on a project when I encountered the problem mentioned in the title, which occurs when nested transactions encounter a short period of database disconnection.
I've reproduced the problem with a short example code.
(Please build a simple MySQL database, configure the example code to connect to it on line 8, and fetch arbitrary data from the database on line 27.)
I can consistently reproduce the problem by restarting the SQL server while the process enters a nested transaction( when the message "1:enter a transaction nest" prompts in the terminal).
The testing environment installed the following packages:
aiomysql==0.1.1
autopep8 @ file:///opt/conda/conda-bld/autopep8_1650463822033/work
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
cryptography==39.0.0
databases==0.7.0
greenlet==2.0.1
pycodestyle @ file:///tmp/build/80754af9/pycodestyle_1636635402688/work
pycparser==2.21
pydantic==1.10.2
PyMySQL==1.0.2
SQLAlchemy==1.4.46
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
typing_extensions==4.4.0
After diving into the problem, I found out the exception will occur while trying to start/begin a transaction in nested transactions. The transaction failed to start due to losing connection to the SQL server, however, the connection counter didn't adjust to the error. Therefore, I tried to fix the problem with additional exception handling. In addition, while proceeding with the aexit function, the transaction would try to perform rollback while the SQL server remains disconnected. I've also attempted to skip the rollback process under such conditions. After the adjustments, the problem is resolved and the connection pool can successfully reconnect to the SQL server.