MagicStack / MagicStack/asyncpg
Prepared Statement connection is active and wait for ClientRead.
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 8.1k
- Forks
- 468
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
Hi team,
Right now, asyncpg does prepared statements in two steps.
- Parse, Describe, Flush.
- Bind, Execute, Sync.
Two coroutines represent these two steps. In a highly concurrent setup, the wall-clock gap between these two steps can be large. Why is it causing a problem for me? Command Flush does not change the connection state, i.e., active. So I observe a lot of queries show up as
wait_event_type | wait_event | state
-----------------+------------+--------
Client | ClientRead | active
in pg_stat_activity. This causes a lot of unnecessary confusion for our database monitors/observability tools. The connection is essentially idle between these two steps, so I think it is better to report it as wait_event=ClientRead but state=idle? Meanwhile, the command Sync will change the connection state to idle, so after step 2, the connection becomes idle.
My ask is: could we use Sync instead of Flush in step 1?
Moreover, there could be more than one bind step, so the sequence could be
1. Parse, Describe, Flush.
2. Bind, Execute, Sync.
3. Bind, Execute, Sync.
...
In this case, the connection is active only between step 1 and step 2, but idle for all other step gaps. I kind of feel this behavior is inconsistent.
I might have neglected some basic design about PostgreSQL extended query. Hope to hear from you soon!
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.
Línea de trabajo
Comienza con el flujo de sentencias preparadas de asyncpg descrito en el issue y la documentación del protocolo de consultas extendidas de PostgreSQL. Determina si cambiar la secuenciación de Flush/Sync puede preservar la corrección con varios pasos de Bind/Execute; se considera terminado cuando pg_stat_activity informa del estado de la conexión de forma consistente sin romper las sentencias preparadas.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- postgresql, python
- Área
- databases
- Tipo de issue
- Error
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 30/100