Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spanner: keep better track of max sessions
The session pool did not keep proper track of the max number of sessions in use within one maintenance window. This change ensures that the max number of sessions in use is actually kept track of per window, and prevents the maintainer from deleting sessions too eagerly. This will change the behavior of the session pool and lead to the pool keeping more sessions in the pool for a longer time, and to less deletion and creation of sessions. The logic is now: 1. Keep track of the max number of sessions in use when a session is taken from the pool, instead of probing this only at the moment that the maintainer is running. This prevents the session pool from missing spikes in session usage. 2. Store the max number of sessions during a health check cycle in a maintenance window struct containing one value for each cycle in an entire window of 10 cycles. 3. Only delete sessions after at least one full maintenance window has passed. After that, the maintainer will delete sessions based on a rolling set of maxSessionsInUse for the last 10 minutes. 4. The shrinkPool and replenishPool both take a max number of sessions to delete/create as an argument in order to prevent the methods from deleting/creating more sessions than intended if the number of sessions in the pool change as a result of other operations on the pool. 5. If the shrinkPool method notices that the session pool has started creating new sessions, the method will stop deleting any further sessions. Fixes #1303, #1382, #1398 and #1406. Change-Id: I20c0821a45b8ce02cb09a9dc492d389da03cccab Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/40150 Reviewed-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Shanika Kuruppu <skuruppu@google.com> Reviewed-by: Jean de Klerk <deklerk@google.com>
- Loading branch information
Showing
2 changed files
with
323 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.