Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repetitive InterfaceError("(0, 'Not Connected')") Error in Nested Transactions. #528

Closed
wants to merge 3 commits into from

Conversation

ODD2
Copy link

@ODD2 ODD2 commented Jan 16, 2023

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.

@ODD2 ODD2 changed the title Repeative InterfaceError("(0, 'Not Connected')") Error in nested Transactions. Repetitive InterfaceError("(0, 'Not Connected')") Error in nested Transactions. Mar 14, 2023
@ODD2 ODD2 changed the title Repetitive InterfaceError("(0, 'Not Connected')") Error in nested Transactions. Repetitive InterfaceError("(0, 'Not Connected')") Error in Nested Transactions. Mar 14, 2023
@zanieb
Copy link
Contributor

zanieb commented Aug 28, 2023

Perhaps resolved by #546 ?

@zanieb zanieb closed this Aug 28, 2023
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.

None yet

2 participants