Invalidate ResultProxy after releasing a connection
- 主要語言
- Python
- 星號
- 1.9k
- 分支
- 272
- PR 合併指標
- 30 天內沒有已合併 PR
描述
At work, we spent two days debugging an issue where we had several threads reading from MySQL and we found a non-deterministic bug when after a few hours of running, our service encountered the exception `pymysql.err.InternalError: Packet sequence number wrong - got 116 expected 1`.
A part of the code reading from MySQL was badly written and looked like this:
```
async with mysql.acquire() as conn:
result = conn.execute(text(sql_string))
# [...]
async for row in result:
pass # do something with it
```
After finding the code, it was trivial to fix it (and this was the last place we looked...) so that we don't try to read from the connection after releasing it back into the pool, but it would've been much easier if all `ResultProxy`s were invalidated in such a way that all attempts to read data that's not already cached would result in an exception.
貢獻指南
評估
這個 Issue 還沒有評估資料。