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

未关闭
#15,908 1 条评论 0 个 reaction 已指派 1 人 已被 @larkee 认领 在 GitHub 查看
api: spanner
主要语言
Python
星标
5.4k
派生
1.8k
平均合并
3 天 4 小时
30 天内合并 PR
122

描述

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()`

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。