MagicStack / MagicStack/asyncpg
A weird log line from the asyncio default exception handler: "Resetting connection with an active transaction"
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 8.1k
- Forks
- 468
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Sometimes our production component logs the following error
21:05:49.897964000 [Error ] [asyncio] Resetting connection with an active transaction <asyncpg.connection.Connection object at 0x7fb1502561f8>
We create a connection pool first.
Then we use async_timeout, prepared statements, explicit transaction and a cursor to get data.
A coroutine that has this logic may be cancelled sometimes, and this is when we may see the error above. However not every
cancellation produces the error. Cancellation happens oftens but we see this error extremely rarely. I wasn't able to build a
minimal example to reproduce it.
We use a connection pool.
Later, in a different coroutine, we use async_timeout, prepared statements, explicit transaction and a cursor.
A coroutine that has this logic may be cancelled sometimes, and this is when we may see the error above. However not every
cancellation produces the error. Cancellation happens oftens but we see this error extremely rarely. I wasn't able to build a
minimal example to reproduce it.
`
pool = await asyncpg.create_pool(...)
async with async_timeout.timeout(global_delay_sec) as cm:
async with pool.acquire() as conn:
stmt = await conn.prepare(sql)
columns = stmt.get_attributes()
...
async with conn.transaction():
cursor = await stmt.cursor()
raw_values = await cursor.fetch(max_rows + 1)
if len(raw_values) == max_rows + 1:
raise Exception(f"A total number of rows exceeded the allowed maximum of {max_rows} rows")
`
-
asyncpg version:
0.20.1 -
PostgreSQL version:
Reproduced with both postgres-11 and 12 -
Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?:
No we don't use PostgreSQL SaaS
I wasn't able to reproce it the issue locally. -
Python version:
3.6.3 -
Platform:
lsb_release -d
Description: CentOS Linux release 7.6.1810 (Core) -
Do you use pgbouncer?:
no -
Did you install asyncpg with pip?:
yes -
If you built asyncpg locally, which version of Cython did you use?:
We do not build it locally -
Can the issue be reproduced under both asyncio and
uvloop?:
I do use uvloop, I couldn't reproduce it locally. It seems to be an extremely rare issue, happens in our production only once in a month
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem gemeldeten Ablauf von pool.acquire, prepared-statement, expliziter Transaktion, Cursor und async_timeout und konzentriere dich auf Abbrüche während der gezeigten Operationen. Vergleiche das Verhalten unter asyncio und uvloop mit den aufgeführten PostgreSQL-Versionen und verwende das nur in der Produktion auftretende Log als zu erklärendes Symptom. Als erledigt gilt die Reproduktion des seltenen Resets oder die Feststellung einer bestätigten Ursache und Lösung.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- postgresql, python
- Bereich
- databases
- Issue-Typ
- Bug
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100