You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue occurs within nested transactions as soon as a short period of disconnection from the database, the databases couldn't automatically reconnect the target database but rather repetitively throws the same exception: InterfaceError("(0, 'Not Connected')").
I'm able to constantly reproduce the issue with a short example code.
(Please build a simple MySQL database, configure the example code to connect the database backend on line 8, and fetch arbitrary data from the database on line 27.)
importsysimportasyncioimportdatabasesapi_db=databases.Database(
"mysql+aiomysql://root:password@mysql-test:3306/testing_db", # the database URL, the selected backend is aiomysqlmin_size=1,
max_size=1
)
# the nested transaction driver function, the default depth of the nest is 3 layers.asyncdefdriver(layer=2):
try:
print(f"{layer}:enter driver")
asyncwithapi_db.transaction(): # start transactionprint(f"{layer}:start transaciton")
if (layer>0):
print(f"{layer}:enter a transaction nest.")
awaitasyncio.sleep(1)
awaitdriver(layer-1) # enter next depthelse:
print(f"{layer}:fetch data from users table.")
awaitapi_db.fetch_all("SELECT * FROM `users` WHERE 1;") # fetch arbitrary data from databasesprint(f"{layer}:fetch done.")
exceptExceptionase:
raiseefinally:
print(f"{layer}:exit driver")
asyncdefmain():
awaitapi_db.connect() # connect to the databasewhileTrue:
try:
awaitdriver()
exceptExceptionase:
print(f"exception occured {repr(e)}")
else:
print("complete successfully")
awaitasyncio.sleep(1)
if__name__=="__main__":
asyncio.run(main())
To reproduce the issue, simply disconnect the database backend while the process enters a nested transaction(e.g. when the message "1:enter a transaction nest" prompts in the terminal).
This issue seems related to the connection leak problem(#498). I've created a pull request #528 similar to #498, which handles the leak problem during the start of a transaction and returns the raised exceptions.
Issue
Dear Community,
The issue occurs within nested transactions as soon as a short period of disconnection from the database, the databases couldn't automatically reconnect the target database but rather repetitively throws the same exception: InterfaceError("(0, 'Not Connected')").
I'm able to constantly reproduce the issue with a short example code.
(Please build a simple MySQL database, configure the example code to connect the database backend on line 8, and fetch arbitrary data from the database on line 27.)
To reproduce the issue, simply disconnect the database backend while the process enters a nested transaction(e.g. when the message "1:enter a transaction nest" prompts in the terminal).
System
The text was updated successfully, but these errors were encountered: