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

feat: add option to wait on session pool creation #2329

Merged
merged 4 commits into from
Mar 13, 2023

Conversation

thiagotnunes
Copy link
Contributor

@thiagotnunes thiagotnunes commented Mar 10, 2023

Adds option to wait for min sessions to be populated in the session pool before returning the database client back to the user. This only done during the database client creation and it is useful for benchmarking.

Example usage:

SpannerOptions options = SpannerOptions
    .newBuilder()
    .setSessionPoolOption(SessionPoolOptions
        .newBuilder()
        .setMinSessions(100)
        .setMaxSessions(400)
        .setWaitForMinSessions(Duration.ofMinutes(5))
        .build())
    .build();
try (Spanner spanner = options.getService()) {
  // This call will wait (at most) 5 minutes for the session pool creation to have 100 sessions. A SpannerException
  // will be thrown if the session pool does not have the min sessions within the wait duration.
  DatabaseClient client = spanner.getDatabaseClient(DatabaseId.of("my-project", "my-instance", "my-database"));

  try (ResultSet resultSet = client.singleUse().executeQuery(Statement.of("SELECT 1"))) {
    if (resultSet.next()) {
      System.out.println(resultSet.getLong(0));
    }
  }
}

Adds option to wait for min sessions to be populated in the session pool
before returning the database client back to the user. This only done
during the database client creation and it is useful for benchmarking.
@thiagotnunes thiagotnunes requested a review from a team as a code owner March 10, 2023 04:23
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: spanner Issues related to the googleapis/java-spanner API. labels Mar 10, 2023

options =
SessionPoolOptions.newBuilder()
.setMinSessions(minSessions + 1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

0 minSessions always succeed, so we increment it by one

Co-authored-by: Knut Olav Løite <[email protected]>
@thiagotnunes thiagotnunes merged commit ff17244 into main Mar 13, 2023
@thiagotnunes thiagotnunes deleted the wait-on-session-pool branch March 13, 2023 00:19
gcf-merge-on-green bot pushed a commit that referenced this pull request Mar 20, 2023
🤖 I have created a release *beep* *boop*
---


## [6.38.0](https://togithub.com/googleapis/java-spanner/compare/v6.37.0...v6.38.0) (2023-03-20)


### Features

* Add option to wait on session pool creation ([#2329](https://togithub.com/googleapis/java-spanner/issues/2329)) ([ff17244](https://togithub.com/googleapis/java-spanner/commit/ff17244ee918fa17c96488a0f7081728cda7b342))
* Add PartitionedUpdate support to executor ([#2228](https://togithub.com/googleapis/java-spanner/issues/2228)) ([2c8ecf6](https://togithub.com/googleapis/java-spanner/commit/2c8ecf6fee591df95ee4abfa230c3fcf0c34c589))


### Bug Fixes

* Correcting the proto field Id for field data_boost_enabled ([#2328](https://togithub.com/googleapis/java-spanner/issues/2328)) ([6159d7e](https://togithub.com/googleapis/java-spanner/commit/6159d7ec49b17f6bc40e1b8c93d1e64198c59dcf))
* Update executeCloudBatchDmlUpdates. ([#2326](https://togithub.com/googleapis/java-spanner/issues/2326)) ([27ef53c](https://togithub.com/googleapis/java-spanner/commit/27ef53c8447bd51a56fdfe6b2b206afe234fad80))


### Dependencies

* Update dependency com.google.cloud:google-cloud-monitoring to v3.14.0 ([#2333](https://togithub.com/googleapis/java-spanner/issues/2333)) ([9c81109](https://togithub.com/googleapis/java-spanner/commit/9c81109e452d6bae2598cf6cf541a09423a8ed6e))
* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.5.0 ([#2335](https://togithub.com/googleapis/java-spanner/issues/2335)) ([5eac2be](https://togithub.com/googleapis/java-spanner/commit/5eac2beb2ce5eebb61e70428e2ac2e11593fc986))
* Update dependency com.google.cloud:google-cloud-trace to v2.13.0 ([#2334](https://togithub.com/googleapis/java-spanner/issues/2334)) ([c461ba0](https://togithub.com/googleapis/java-spanner/commit/c461ba0b1a145cc3e9bee805ec6ad827376e5168))

---
This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
arpan14 pushed a commit to arpan14/java-spanner that referenced this pull request Apr 28, 2023
🤖 I have created a release *beep* *boop*
---


## [6.38.0](https://togithub.com/googleapis/java-spanner/compare/v6.37.0...v6.38.0) (2023-03-20)


### Features

* Add option to wait on session pool creation ([googleapis#2329](https://togithub.com/googleapis/java-spanner/issues/2329)) ([ff17244](https://togithub.com/googleapis/java-spanner/commit/ff17244ee918fa17c96488a0f7081728cda7b342))
* Add PartitionedUpdate support to executor ([googleapis#2228](https://togithub.com/googleapis/java-spanner/issues/2228)) ([2c8ecf6](https://togithub.com/googleapis/java-spanner/commit/2c8ecf6fee591df95ee4abfa230c3fcf0c34c589))


### Bug Fixes

* Correcting the proto field Id for field data_boost_enabled ([googleapis#2328](https://togithub.com/googleapis/java-spanner/issues/2328)) ([6159d7e](https://togithub.com/googleapis/java-spanner/commit/6159d7ec49b17f6bc40e1b8c93d1e64198c59dcf))
* Update executeCloudBatchDmlUpdates. ([googleapis#2326](https://togithub.com/googleapis/java-spanner/issues/2326)) ([27ef53c](https://togithub.com/googleapis/java-spanner/commit/27ef53c8447bd51a56fdfe6b2b206afe234fad80))


### Dependencies

* Update dependency com.google.cloud:google-cloud-monitoring to v3.14.0 ([googleapis#2333](https://togithub.com/googleapis/java-spanner/issues/2333)) ([9c81109](https://togithub.com/googleapis/java-spanner/commit/9c81109e452d6bae2598cf6cf541a09423a8ed6e))
* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.5.0 ([googleapis#2335](https://togithub.com/googleapis/java-spanner/issues/2335)) ([5eac2be](https://togithub.com/googleapis/java-spanner/commit/5eac2beb2ce5eebb61e70428e2ac2e11593fc986))
* Update dependency com.google.cloud:google-cloud-trace to v2.13.0 ([googleapis#2334](https://togithub.com/googleapis/java-spanner/issues/2334)) ([c461ba0](https://togithub.com/googleapis/java-spanner/commit/c461ba0b1a145cc3e9bee805ec6ad827376e5168))

---
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
Labels
api: spanner Issues related to the googleapis/java-spanner API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants