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 件 担当者 1 名 @larkee が担当を希望しています GitHub で見る
api: spanner
主要言語
Python
スター
5.4k
フォーク
1.8k
平均マージ
3日 4時間
マージ済み PR(30日)
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 を短くまとめたダイジェスト。