aio-libs / aio-libs/aiomysql

OperationalError during ROLLBACK or COMMIT deadlocks entire sa engine

オープン
#353 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug sqlalchemy
主要言語
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 はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。