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
- Langage dominant
- Python
- Étoiles
- 5.4k
- Forks
- 1.8k
- Merge moyen
- 3 j 4 h
- PR mergées (30 j)
- 122
Description
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()`
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.