aio-libs / aio-libs/aiomysql

Invalidate ResultProxy after releasing a connection

Aberta
#371 2 comentários 0 reações 0 responsáveis Ver no GitHub
bug
Linguagem predominante
Python
Estrelas
1.9k
Forks
272
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

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.

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.