Terminate function does not work when a stream is cancelled prematurely when in an anyio task group
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
La reproducción mínima está enlazada en la discusión de SQLAlchemy; empieza ejecutándola con la configuración de asyncpg y anyio indicada, y sigue el recorrido close-then-terminate durante la cancelación del grupo de tareas. Usa los puntos de entrada terminate y close de asyncpg para localizar el manejo del ciclo de vida de la conexión. Se considera terminado cuando un stream cancelado ya no deja la conexión en estado idle in transaction.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
- asyncpg version: 0.29.0
- PostgreSQL version: 14.10
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: Yes, I can reproduce it locally - Python version: 3.12
- Platform: linux and Mac OS
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
- If you built asyncpg locally, which version of Cython did you use?: n/a
- Can the issue be reproduced under both asyncio and
uvloop?: No, the issue is not producible with asyncio only with anyio
Hi, I have a Fast API application that uses SQLAlchemy and asyncpg. I opened up a discussion on the SQLAlchemy page here (full discussion) reporting a major problem that affected my application after an update they released.
To summarize the problem and what we concluded in that discussion,
I asynchronously stream data from my API to a client using the starlette StreamingResponse class which takes advantage ofanyio under the hood. For some reason when the anyio task group gets cancelled before the stream is finished the asyncpg terminate function does not terminate the connection when the close function is used first, leaving it stuck in an idle in transaction state. This causes connections to run up eventually stopping other applications from creating new connections.
With some help from the SQLAlchemy folks, after some time working through the problem we were able to reproduce a small example of my problem using only the asyncpg and anyio libraries here (Example of problem)
Any help resolving this issue would be greatly appreciated! If you need any more info from me please do not hesitate to message back
Thanks in advance!
- Lenguaje dominante
- Python
- Estrellas
- 8.1k
- Forks
- 469
- Merge medio
- 2 d 20 h
- PR fusionados (30 d)
- 9
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MagicStack/asyncpg
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
MagicStack/asyncpg#1357 · 1 comentario · 1 reacción ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
MagicStack/asyncpg#1342 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 56/100
MagicStack/asyncpg#1340 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 28/100
MagicStack/asyncpg#1337 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
MagicStack/asyncpg#1330 · 1 comentario ·
Todos los issues de MagicStack/asyncpg
Issues similares
-
bug confirmed issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
open-webui/open-webui#30750 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 comentario ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
good first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100