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
Nothing work with "Pool has been closed" error when no queries are executed for a while #202
Comments
@fiarabbit Thanks for reporting the issue and providing code to reproduce. |
@fiarabbit Thanks for the detailed report. @meltsufin No, I didn't know about it and it does surprise me a little, as I normally have a DBeaver instance opened with multiple JDBC connections open to Cloud Spanner databases for days in a row, without ever seeing this error. But with the extensive information in this issue I think I'll be able to reproduce and fix it. I'll make a separate issue in the JDBC driver repository. |
Thanks for a speedy response @olavloite. We will wait for your triage of the issue. |
@fiarabbit Would you mind sharing exactly how you are creating the credentials that you are using? The reason that I am asking is that in most cases you would be using either If you are using an instance of either EDIT: I'm also very interested in any connection pooling or other JDBC connection management that might also be involved here. |
@olavloite Thanks for your support. 1The credential used in my case is 2You can see that jdbc-connection removal does not work out of
This does not throw any
|
|
Description
EntityManager
and do some queryEntityManager
and do some query againThe query in 3. will fail with
IllegalStateException: Pool has been closed
Environment
Environment 1
com.google.cloud:google-cloud-spanner:1.46.0
com.google.cloud:google-cloud-spanner-hibernate-dialect:1.0.0
com.google.cloud:google-cloud-spanner-jdbc:1.11.0
Environment 2 (Also seen)
com.google.cloud:google-cloud-spanner:1.52.0
com.google.cloud:google-cloud-spanner-hibernate-dialect:1.2.0
com.google.cloud:google-cloud-spanner-jdbc:1.15.0
Code to Reproduce
Error Message
Cause
This bug is caused by another bug in
google-cloud-spanner-jdbc
:com.google.cloud.spanner.jdbc.SpannerPool.SpannerPoolKey.hashCode()
includescom.google.auth.Credentials
in its hashCode target, butOAuth2Credentials.requestMetadata
andOAuth2Credentials.temporaryAccess
(the actual implementation ofCredentials
) is not initialized first but initialized viaCredentials.getRequestMetadata()
by mutation.This intervenes
SpannerPoolKey
to work as "key" ofjava.util.HashMap
, in which the key must not be modified after registration as the key.This causes error in
com.google.cloud.spanner.jdbc.SpannerPool.closeUnusedSpanners
, which is called every 60 secs, and potentially cause the "Pool has been closed" error.Workaround
The patch workaround is inserting
into some initializer block. This initializes global
Credential
object and prevents the incongruence. However, this might not work for rotation ofOAuth2Credentials.temporaryAccess
, so better idea might be necessary as permanent measures.The text was updated successfully, but these errors were encountered: