googleapis / googleapis/google-cloud-python

FixedSizePool.bind unconditionally requests for the same session count on every loop iteration, hence could end up creating much more sessions than necessary; should decrement them per call

Abierto
#15,908 1 comentario 0 reacciones 1 asignado Reclamado por @larkee Ver en GitHub
api: spanner
Lenguaje dominante
Python
Estrellas
5.4k
Forks
1.8k
Merge medio
3 d 4 h
PR fusionados (30 d)
122

Descripción

Found while I was writing tests for PR googleapis/python-spanner#1207 that this code in each iteration requests for the original number of sessions in every loop iteration
https://github.com/googleapis/python-spanner/blob/e15e84f3d18f0e8e635fee38ba62a654c58c9a00/google/cloud/spanner_v1/pool.py#L208-L216
and the basic tests inside tests/unit/test_pool.py when ran, the loop runs twice but each time the count is kept the exact same per https://github.com/googleapis/python-spanner/blob/e15e84f3d18f0e8e635fee38ba62a654c58c9a00/google/cloud/spanner_v1/pool.py#L209-L212

You can add prints and you'll see that the loop runs twice but each time 2 sessions are returned but yet 4 sessions were requested

## Suggestion
The correct remedy for this is that per iteration, the current size of the filled in queue must be considered in relation to filling it up `request.session_count = requested_session_count - self._sessions.qsize()`

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.