GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — spanner: Enhance session pool behavior by vkedia · Pull Request #2026 · googleapis/google-cloud-java

Conversation

@vkedia

@vkedia vkedia commented May 1, 2017

Copy link
Copy Markdown
  • Change defaults for maxSessions and blockIfExhauseted
  • Added tracking of leaked sessions
  • Changed closeAsync to close leaked sessions as well.
  • Changed closeAsync to close pool maintenance worker as well.
  • Added a SessionPoolStressTester
  • Changed Spanner#closeAsync to be blocking Spanner#close.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
vkedia added 7 commits May 1, 2017 10:12
@vkedia
Enhancements to session pool <BREAKING CHANGE>.
a9c8d57
- Change defaults for maxSessions and blockIfExhauseted
- Changed closeAsync to close leaked sessions as well.
- Changed closeAsync to close pool maintenance worker as well.
- Added a SessionPoolStressTester
- Changed Spanner#closeAsync to be blocking Spanner#close.
@vkedia
Formatting fixes
3a308a6
@vkedia
Merge branch 'master' into session-pool-exception
935407d
@vkedia
Added license headers
1bb879b
@vkedia
Changed Instant type
5fa0f0f
@vkedia
Track where the session was closed at
125753e
@vkedia
Track expired sessions
c9d56df
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 1, 2017
@vkedia
vkedia requested a review from vam-google May 1, 2017 20:45
@vkedia

vkedia commented May 1, 2017

Copy link
Copy Markdown
Author

@tomayles Please take a look

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented May 1, 2017

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.006%) to 80.954% when pulling c9d56df on vkedia:session-pool-exception into 9623994 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkedia vkedia closed this May 1, 2017
@vkedia
Fixed codacy commant and some other stylistic things
ae8860f
@vkedia vkedia reopened this May 1, 2017
@vkedia

vkedia commented May 1, 2017

Copy link
Copy Markdown
Author

Closed by mistake.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced May 1, 2017
Spanner service never completes a closeAsync when there is an unused ReadContext #1986
Closed
Spanner - Running Spanner on AppEngine SDK throws an NPE #1856
Closed
Shade Guava in google-cloud-spanner #1802
Closed
@coveralls

coveralls commented May 1, 2017

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.009%) to 80.952% when pulling ae8860f on vkedia:session-pool-exception into 9623994 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

danielcompton
danielcompton reviewed May 1, 2017
View reviewed changes

@danielcompton danielcompton left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so keen on Spanner changing from closeAsync to close. It is handy to be able to set a timeout when closing the Spanner to handle cases where it gets blocked for whatever reason. At the bottom, this ends up doing (blocking?) RPC calls to deleteSession. Perhaps this is totally safe, if so, it could be good to add a note about this in the implementation notes?

I'm not sure if this is throwing the kitchen sink in, but having close and closeAsync might be useful.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java Outdated
* #getReadWriteSession()} will start throwing {@code IllegalStateException}. The returned {@code
* ListenableFuture} blocks till all the sessions created in this pool have been closed.
* Close all the sessions. Once this method is invoked {@link #getReadSession()} and {@link
* #getReadWriteSession()} will start throwing {@code IllegalStateException}. This method blocks

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/Spanner.java
* logging and tracking of leaked sessions.
*/
ApiFuture<Void> closeAsync();
void close();

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkedia
Fixed javadocs
531f73c
@coveralls

coveralls commented May 1, 2017

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.009%) to 80.952% when pulling 531f73c on vkedia:session-pool-exception into 9623994 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danielcompton

danielcompton commented May 1, 2017

Copy link
Copy Markdown

Thanks for updating the javadocs. I'm still a little uneasy about having blocking RPC calls in the shutdown path though.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkedia

vkedia commented May 1, 2017 via email

Copy link
Copy Markdown
Author
Thanks for your comments. It is almost essential that this method be allowed to finish and delete all the sessions otherwise it can lead to session lying around on the backend for upto an hour. Since there is a [hard limit](https://cloud.google.com/spanner/docs/limits) on how many sessions one can have on the backend, this can lead to one running out of sessions which will cause requests to fail. That is the reason I removed the async version. You almost always want to block for this method to finish.
…
On Mon, May 1, 2017 at 3:47 PM, Daniel Compton ***@***.***> wrote: Thanks for updating the javadocs. I'm still a little uneasy about having blocking RPC calls in the shutdown path though. — You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub <#2026 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ATdefzp5iSCWxKfhSyeI8DA2rGGLmXRTks5r1mDsgaJpZM4NNavX> .
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkedia
Fixed javadocs
1d867bf
@coveralls

coveralls commented May 1, 2017

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.009%) to 80.952% when pulling 1d867bf on vkedia:session-pool-exception into 9623994 on GoogleCloudPlatform:master.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vam-google
vam-google reviewed May 2, 2017
View reviewed changes
Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java Outdated
private static final long serialVersionUID = 1451131180314064914L;

private LeakedSessionException() {
super("Session was checked out from the pool at:");

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java Outdated

// Exception class used just to track the stack trace at the point when a session was handed out
// from the pool.
private final class LeakedSessionException extends Exception {

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java Outdated

void close() {
scheduledFuture.cancel(false);
if (!running) {

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/Spanner.java
* unused sessions piling up on the backend.
*/
ApiFuture<Void> closeAsync();
void close();

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerImpl.java Outdated
throw SpannerExceptionFactory.newSpannerException(e);
}
for (ManagedChannel channel : getOptions().getRpcChannels()) {
channel.shutdown();

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java Outdated
releaseSession(new PooledSession(session));
Preconditions.checkState(totalSessions() <= options.getMaxSessions() - 1);
PooledSession pooledSession = new PooledSession(session);
allSessions.put(session.getName(), pooledSession);

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tomayles
tomayles reviewed May 3, 2017
View reviewed changes
Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java Outdated

/** Options for the session pool used by {@code DatabaseClient}. */
public class SessionPoolOptions {
private static final int DEFAULT_MAX_SESSIONS = 2000;

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tomayles
tomayles reviewed May 3, 2017
View reviewed changes
Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java Outdated
/** Options for the session pool used by {@code DatabaseClient}. */
public class SessionPoolOptions {
private static final int DEFAULT_MAX_SESSIONS = 2000;
private static final ActionOnExhaustion DEFAULT_ACTION = ActionOnExhaustion.FAIL;

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tomayles
tomayles reviewed May 3, 2017
View reviewed changes
Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/Spanner.java Outdated
/**
* An interface for Cloud Spanner. Typically, there would only be one instance of this for the
* lifetime of the application which must be closed by invoking {@link #close()} when it is no
* longer needed.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tomayles
tomayles reviewed May 3, 2017
View reviewed changes
Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/Spanner.java Outdated
* Closes all the clients associated with this instance and frees up all the resources. This
* method does not block. Return future will complete when cleanup is done. TODO(user): Add
* logging and tracking of leaked sessions.
* method will block till it can clean up all the resources. Specifically, it deletes all the

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tomayles
tomayles reviewed May 3, 2017
View reviewed changes
Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java
writePreparedSessions.clear();
for (final PooledSession session : ImmutableList.copyOf(allSessions.values())) {
if (session.leakedException != null) {
logger.log(Level.WARNING, "Leaked session", session.leakedException);

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vkedia added 3 commits May 8, 2017 14:29
@vkedia
Fixed review comment
90d5ef2
@vkedia
Formatting fixes
ac88a50
@vkedia
Merge branch 'master' into session-pool-exception
2677fd0
@vkedia

vkedia commented May 8, 2017

Copy link
Copy Markdown
Author

@tomayles @vam-google Please take a look again.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vam-google
vam-google approved these changes May 9, 2017
View reviewed changes

@vam-google vam-google left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-cloud-spanner/src/main/java/com/google/cloud/spanner/Spanner.java
* unused sessions piling up on the backend.
*/
ApiFuture<Void> closeAsync();
void close();

This comment was marked as spam.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tomayles
tomayles approved these changes May 10, 2017
View reviewed changes
vkedia added 4 commits May 10, 2017 11:37
@vkedia
Merge branch 'master' into session-pool-exception
a5f74aa
@vkedia
Fixed a race between health checker and pool closure logic
18b591a
@vkedia
Merge branch 'master' into session-pool-exception
f8b8953
@vkedia
Formatting fixes
2b385eb
@coveralls

coveralls commented May 12, 2017

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 2b385eb on vkedia:session-pool-exception into ** on GoogleCloudPlatform:master**.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coveralls

coveralls commented May 12, 2017

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 2b385eb on vkedia:session-pool-exception into ** on GoogleCloudPlatform:master**.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkedia
Changed log to be FINE as it was too spammy
710701b
@coveralls

coveralls commented May 12, 2017

Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 710701b on vkedia:session-pool-exception into ** on GoogleCloudPlatform:master**.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkedia
vkedia merged commit 8db50cc into googleapis:master May 12, 2017
@vkedia
vkedia deleted the session-pool-exception branch May 12, 2017 17:43
chingor13 pushed a commit that referenced this pull request Feb 20, 2026
@release-please
chore(main): release 2.33.1 (#2026)
7a95553
🤖 I have created a release *beep* *boop*
---


## [2.33.1](https://togithub.com/googleapis/java-bigquerystorage/compare/v2.33.0...v2.33.1) (2023-03-02)


### Dependencies

* Update dependency com.google.cloud:google-cloud-bigquery to v2.23.0 ([#2012](https://togithub.com/googleapis/java-bigquerystorage/issues/2012)) ([0651aa6](https://togithub.com/googleapis/java-bigquerystorage/commit/0651aa6f3e83da73da77ae2e9376f6203cd36338))
* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.4.0 ([#2024](https://togithub.com/googleapis/java-bigquerystorage/issues/2024)) ([9135769](https://togithub.com/googleapis/java-bigquerystorage/commit/91357697f61d3026ae3fb14605e9e3ee94b351d1))
* Update dependency com.google.http-client:google-http-client to v1.43.0 ([#2018](https://togithub.com/googleapis/java-bigquerystorage/issues/2018)) ([6bccd9d](https://togithub.com/googleapis/java-bigquerystorage/commit/6bccd9d21698fa94645bfdda2e7d4e70af612d6b))
* Update dependency org.json:json to v20230227 ([#2020](https://togithub.com/googleapis/java-bigquerystorage/issues/2020)) ([6d6bb76](https://togithub.com/googleapis/java-bigquerystorage/commit/6d6bb76188d4be6beec88c54946d6f9515962c55))

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
suztomo pushed a commit to suztomo/google-cloud-java that referenced this pull request Mar 23, 2026
@olavloite
docs: add sample for MyBatis with GoogleSQL (googleapis#2026)
787096e
meltsufin pushed a commit that referenced this pull request May 2, 2026
@renovate-bot
deps: update googleapis/sdk-platform-java action to v2.54.0 (#2026)
5b512c1
benjaminp pushed a commit to benjaminp/google-cloud-java that referenced this pull request Jul 13, 2026
@mutianf
feat: handle retry info so client respect the delay server sets (goog…
96e6011
…leapis#2026)

* feat: add a flag to add / remove routing cookie from callable chain
benjaminp pushed a commit to benjaminp/google-cloud-java that referenced this pull request Jul 13, 2026
@release-please
chore(main): release 2.31.0 (googleapis#2034)
335cddb
🤖 I have created a release *beep* *boop*
---


## [2.31.0](https://togithub.com/googleapis/java-bigtable/compare/v2.30.0...v2.31.0) (2024-01-12)


### Features

* Add a flag to add / remove routing cookie from callable chain ([googleapis#2032](https://togithub.com/googleapis/java-bigtable/issues/2032)) ([8d08406](https://togithub.com/googleapis/java-bigtable/commit/8d08406d1775cf4274ae712f75511043c2800001))
* Adding feature flags for routing cookie and retry info ([googleapis#2031](https://togithub.com/googleapis/java-bigtable/issues/2031)) ([450af14](https://togithub.com/googleapis/java-bigtable/commit/450af14068131c27fb42176bca779df67cf6e292))
* Count row merging errors as internal errors ([googleapis#2045](https://togithub.com/googleapis/java-bigtable/issues/2045)) ([68b8f0b](https://togithub.com/googleapis/java-bigtable/commit/68b8f0b9dacf631836377c62aa9723d06af73536))
* Enable feature flag when setting is enabled ([googleapis#2043](https://togithub.com/googleapis/java-bigtable/issues/2043)) ([29e67f2](https://togithub.com/googleapis/java-bigtable/commit/29e67f2f128027ee944e7f09ff1a5a575e611531))
* Handle retry info so client respect the delay server sets ([googleapis#2026](https://togithub.com/googleapis/java-bigtable/issues/2026)) ([96e6011](https://togithub.com/googleapis/java-bigtable/commit/96e60112db170f7f6615687436a0ca6814917552))


### Bug Fixes

* **deps:** Update the Java code generator (gapic-generator-java) to 2.31.0 ([googleapis#2044](https://togithub.com/googleapis/java-bigtable/issues/2044)) ([1c0b376](https://togithub.com/googleapis/java-bigtable/commit/1c0b3764058a9cc50c25650e231b448aed4555dc))
* Fix RetryInfo algorithm and tests ([googleapis#2041](https://togithub.com/googleapis/java-bigtable/issues/2041)) ([9fa2bd5](https://togithub.com/googleapis/java-bigtable/commit/9fa2bd56ceb0e797d92d67741442a37a53461abc))


### Dependencies

* Update dependency com.google.cloud:gapic-libraries-bom to v1.27.0 ([googleapis#2030](https://togithub.com/googleapis/java-bigtable/issues/2030)) ([9ee2f56](https://togithub.com/googleapis/java-bigtable/commit/9ee2f56ab74774dd35c2d8dc6a5628e75e8c3698))
* Update dependency com.google.truth.extensions:truth-proto-extension to v1.2.0 ([googleapis#2035](https://togithub.com/googleapis/java-bigtable/issues/2035)) ([ffd8af3](https://togithub.com/googleapis/java-bigtable/commit/ffd8af39afb770f8dc3ef6622942f2141a8141fc))

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

3 more reviewers
@danielcompton danielcompton danielcompton left review comments
@tomayles tomayles tomayles approved these changes
@vam-google vam-google vam-google approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@vkedia @coveralls @danielcompton @tomayles @vam-google @googlebot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.