OperationalError during ROLLBACK or COMMIT deadlocks entire sa engine
- 主要語言
- Python
- 星號
- 1.9k
- 分支
- 272
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Didn't dive deeper, because in my case it is enough to just set autocommit=True and get rid of all transactions, but here is a minimal test reproducing a problem (v0.0.19), at least giving very similar results:
``` python
engine = await create_engine(
...
autocommit=False,
)
async def test_mysql_connection_error():
used = engine._pool._used
assert len(used) == 0
with pytest.raises(aiomysql.OperationalError):
with mock.patch('aiomysql.sa.connection.SAConnection.execute',
side_effect=aiomysql.OperationalError):
with mock.patch('aiomysql.sa.transaction.Transaction.rollback',
side_effect=aiomysql.OperationalError):
async with engine.acquire() as conn: # type: SAConnection
async with conn.begin():
qs = table.select()
await conn.execute(qs)
used = mysql.engine._pool._used
assert len(used) == 0
async def test_mysql_connection_error2():
used = mysql.engine._pool._used
assert len(used) == 0
with pytest.raises(aiomysql.OperationalError):
with mock.patch('aiomysql.sa.transaction.Transaction.commit',
side_effect=aiomysql.OperationalError):
async with engine.acquire() as conn: # type: SAConnection
async with conn.begin():
qs = table.select()
await conn.execute(qs)
used = mysql.engine._pool._used
assert len(used) == 0
```
貢獻指南
評估
這個 Issue 還沒有評估資料。