googleapis / java-spanner Public
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
fix: closes pool maintainer on invalidation #784
fix: closes pool maintainer on invalidation #784
Conversation
When the session pool is marked as invalid, we immediately close the pool maintainer in order to keep it from trying to replinish the pool. This way we prevent useless batch create sessions requests.
This fixes the following problem
|
Codecov Report
@@ Coverage Diff @@
## master #784 +/- ##
============================================
+ Coverage 85.01% 85.06% +0.05%
- Complexity 2561 2564 +3
============================================
Files 143 143
Lines 14005 14037 +32
Branches 1337 1344 +7
============================================
+ Hits 11906 11941 +35
+ Misses 1537 1533 -4
- Partials 562 563 +1 Continue to review full report at Codecov.
|
@thiagotnunes I just thought of one small catch with this:
The above is probably also the reason that a number of the tests were cancelled, because they never finished (still waiting for the session pool to close). The solution would be to only conditionally do +1 in step 2 above for the pool maintainer. If it has already been closed because the session pool is invalid, then we should not wait for it to close. |
@olavloite Thanks for spotting this, will work on the fix. |
When closing the pool, only waits for the pool maintainer to close if it has not been closed before.
Makes sure to close the pool maintainer only if it has not been closed already. Also before returning to the caller, makes sure to mark the closing as complete if there are no pending closures.
@olavloite Fixed the implementation, now we only close the |
google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java
Outdated
Show resolved
Hide resolved
Some tests seem to be getting stuck eventually, I think I introduced a bug somewhere. Will mark it as do not merge until I had the time to investigate. |
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
Verifies that the pool maintainer is not closed before closing it. Also moves the check of pendingClosures into the synchronized block to make sure no stale reads are made.
* fix: closes pool maintainer on invalidation When the session pool is marked as invalid, we immediately close the pool maintainer in order to keep it from trying to replinish the pool. This way we prevent useless batch create sessions requests. * fix: checks for pool maintainer closed status When closing the pool, only waits for the pool maintainer to close if it has not been closed before. * fix: only closes pool maintainer if not closed Makes sure to close the pool maintainer only if it has not been closed already. Also before returning to the caller, makes sure to mark the closing as complete if there are no pending closures. * fix: avoids npe when closing pool maintainer * fix: checks pool maintainer is not closed on close Verifies that the pool maintainer is not closed before closing it. Also moves the check of pendingClosures into the synchronized block to make sure no stale reads are made.
When the session pool is marked as invalid, we immediately close the pool maintainer in order to keep it from trying to replenish the pool. This way we prevent useless batch create sessions requests.
Fixes #768