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 #1226
Labels
api: spanner
Issues related to the googleapis/python-spanner API.
Found while I was writing tests for PR #1207 that this code in each iteration requests for the original number of sessions in every loop iteration
python-spanner/google/cloud/spanner_v1/pool.py
Lines 208 to 216 in e15e84f
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
python-spanner/google/cloud/spanner_v1/pool.py
Lines 209 to 212 in e15e84f
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()
The text was updated successfully, but these errors were encountered: