-
Notifications
You must be signed in to change notification settings - Fork 123
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: long running transaction clean up background task. Adding configuration options for closing inactive transactions. #2419
Conversation
…od while retrying exceptions in unit tests. * For details on issue see - googleapis#2206
fix: prevent illegal negative timeout values into thread sleep() method while retrying exceptions in unit tests.
…guration options for closing inactive transactions.
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.
The log of the integration tests for the emulator (and possibly also for the other test runs) are spammed with a very large number of warnings for closed long-running transactions.
- Is that expected? Or are we accidentally removing a lot more sessions from the pool than we should?
- If it is expected, can we somehow silence that log? It now makes the log too large to be really useful.
google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java
Show resolved
Hide resolved
google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java
Outdated
Show resolved
Hide resolved
google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java
Show resolved
Hide resolved
google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java
Outdated
Show resolved
Hide resolved
google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java
Outdated
Show resolved
Hide resolved
google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java
Outdated
Show resolved
Hide resolved
google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java
Outdated
Show resolved
Hide resolved
google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java
Outdated
Show resolved
Hide resolved
google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java
Outdated
Show resolved
Hide resolved
google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java
Show resolved
Hide resolved
…ssionPool.java Co-authored-by: Knut Olav Løite <[email protected]>
…ssionPoolOptions.java Co-authored-by: Knut Olav Løite <[email protected]>
…ssionPoolOptions.java Co-authored-by: Knut Olav Løite <[email protected]>
…ssionPoolOptions.java Co-authored-by: Knut Olav Løite <[email protected]>
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
google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java
Show resolved
Hide resolved
🤖 I have created a release *beep* *boop* --- ## [6.45.0](https://togithub.com/googleapis/java-spanner/compare/v6.44.0...v6.45.0) (2023-08-04) ### Features * Enable leader aware routing by default in Connection API. This enables its use in the JDBC driver and PGAdapter. The update contains performance optimisations that will reduce the latency of read/write transactions that originate from a region other than the default leader region. ([2a85446](https://togithub.com/googleapis/java-spanner/commit/2a85446b162b006ce84a86285af1767c879b27ed)) * Enable leader aware routing by default. This update contains performance optimisations that will reduce the latency of read/write transactions that originate from a region other than the default leader region. ([441c1b0](https://togithub.com/googleapis/java-spanner/commit/441c1b03c3e976c6304a99fefd93b5c4291e5364)) * Long running transaction clean up background task. Adding configuration options for closing inactive transactions. ([#2419](https://togithub.com/googleapis/java-spanner/issues/2419)) ([423e1a4](https://togithub.com/googleapis/java-spanner/commit/423e1a4b483798d9683ff9bd232b53d76e09beb0)) * Support partitioned queries + data boost in Connection API ([#2540](https://togithub.com/googleapis/java-spanner/issues/2540)) ([4e31d04](https://togithub.com/googleapis/java-spanner/commit/4e31d046f5d80abe8876a729ddba045c70f3261d)) ### Bug Fixes * Apply stream wait timeout ([#2544](https://togithub.com/googleapis/java-spanner/issues/2544)) ([5a12cd2](https://togithub.com/googleapis/java-spanner/commit/5a12cd29601253423c5738be5471a036fd0334be)) ### Dependencies * Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.14.0 ([#2562](https://togithub.com/googleapis/java-spanner/issues/2562)) ([dbd5c75](https://togithub.com/googleapis/java-spanner/commit/dbd5c75be39262003092ff4a925ed470cc45f8be)) * Update dependency org.openjdk.jmh:jmh-core to v1.37 ([#2565](https://togithub.com/googleapis/java-spanner/issues/2565)) ([d5c36bf](https://togithub.com/googleapis/java-spanner/commit/d5c36bfbb67ecb14854944779da6e4dbd93f3559)) * Update dependency org.openjdk.jmh:jmh-generator-annprocess to v1.37 ([#2566](https://togithub.com/googleapis/java-spanner/issues/2566)) ([73e92d4](https://togithub.com/googleapis/java-spanner/commit/73e92d42fe6d334b6efa6485246dc67858adb0a9)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
* | ||
* @return this builder for chaining | ||
*/ | ||
Builder setWarnAndCloseIfInactiveTransactions() { |
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.
why are we making these methods package protected?
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.
@psinghbay1 This feature is not yet launched. Hence it is package protected in this PR. We will be enabling this in the next couple of weeks.
Any reason we are keeping these methods package protected in builder class? |
Adding a couple of option in
SessionPoolOptions
for auto-detecting long running transactions, logging the stack-trace and removing such transactions from consuming more resources. There can be scenarios where transactions are unexpectedly taking more time and hence can consume thesession
for longer durations. With this change, customers get two new options which can be set while providingSessionPoolOptions
setWarnIfInactiveTransactions()
- Calling this method will generate warning logs and help in identifying faulty code which is leading to incorrect consumption of sessions.setWarnAndCloseIfInactiveTransactions()
- Calling this method will close the faulty transactions that are consuming the resources. We will also be generating the warning logs which can be later referred to know the transactions that were closed through this option.Note : The feature is currently under development. The final usage pattern will be updated in a subsequent commit.