Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session pool should not create new sessions when pending < numWaiters #790

Closed
olavloite opened this issue Jan 7, 2020 · 0 comments · Fixed by #791
Closed

Session pool should not create new sessions when pending < numWaiters #790

olavloite opened this issue Jan 7, 2020 · 0 comments · Fixed by #791
Assignees
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@olavloite
Copy link
Contributor

The session pool should not initiate the creation of new sessions if the current number of sessions being created is greater than current number of waiters for a session when an application requests a session. Instead, the requester should be placed in a waiter queue and wait for one of the pending sessions to become available.

The following example will create a session pool with 101 sessions instead of 100, as there is no session available yet when the query is being executed. Instead of waiting for the session pool initialization to return one of the 100 sessions being created, the query will also initiate the creation of a session.

const database = instance.database({
  writes: 0.2,
  min: 100,
  max: 200,
});
const [rows] = await database.run('SELECT * FROM FOO');
@olavloite olavloite added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jan 7, 2020
@olavloite olavloite self-assigned this Jan 7, 2020
olavloite added a commit to olavloite/nodejs-spanner that referenced this issue Jan 7, 2020
The session pool would always initiate the creation of a new session
if one was not available at the moment that an application requested
a session, even when a large number of sessions were already pending
creation. This could cause the pool to create more sessions than
necessary for an application.

Fixes googleapis#790.
olavloite added a commit that referenced this issue Jan 8, 2020
* fix: session pool should only create session if pending<=waiters

The session pool would always initiate the creation of a new session
if one was not available at the moment that an application requested
a session, even when a large number of sessions were already pending
creation. This could cause the pool to create more sessions than
necessary for an application.

Fixes #790.

* fix: add clarifying comment
AVaksman pushed a commit to AVaksman/nodejs-spanner that referenced this issue Jan 21, 2020
…gleapis#791)

* fix: session pool should only create session if pending<=waiters

The session pool would always initiate the creation of a new session
if one was not available at the moment that an application requested
a session, even when a large number of sessions were already pending
creation. This could cause the pool to create more sessions than
necessary for an application.

Fixes googleapis#790.

* fix: add clarifying comment
@google-cloud-label-sync google-cloud-label-sync bot added the api: spanner Issues related to the googleapis/nodejs-spanner API. label Jan 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/nodejs-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant