Invalidate ResultProxy after releasing a connection
- Lingua principale
- Python
- Stelle
- 1.9k
- Fork
- 272
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.