-
Notifications
You must be signed in to change notification settings - Fork 105
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
Spanner Client Multiple Databases & Session Pools Support #2176
Comments
@olavloite and @rahul2393 . What are your thoughts on the above issue. |
@spicydev : Could you reach out to us through a support ticket? we would like to better understand your use case. |
@spicydev, Have you logged a support ticket for it? |
Yes. I did log a support ticket for this issue. |
@spicydev Sorry, I missed this the last time I was tagged. Do you know what version of the Java client Spring Data pulls in in your case? |
Hi @olavloite , To your question, we are currently using the v3.1.1 Spanner java client based on spring boot 2.3.12.RELEASE But the above bug is still replicable with latest version of the Spanner java client. Then problem is that when we are trying to create multiple spanner database-clients with Opencensus metrics instrumented. The second database-client fails to create the session pool at the following method: SessionPool.initMetricsCollection(). Possible fix would be allowing the consumers of library to add metrics name prefix or adding the database name to metrics by default so that two database-clients can use different metric names and we can monitor both session pools separately in GCP Metrics Explorer. Let me know if more information is needed. Thanks |
Is your feature request related to a problem? Please describe.
Yes, Recently in my project I've tried to configure spanner java client to connect to multiple databases from different spanner instances using the Spring Data Framework with multiple SpannerTemplate Beans.
This worked flawlessly but the problem started when we instrumented the app to export Opencensus metrics to Stackdriver using the Opencensus Implementation & exporter. Then we started to notice below blocking error that makes the second database inoperable to write or read data from.
StackTrace:
java.lang.IllegalArgumentException: A different metric with the same name already registered.
at io.opencensus.implcore.metrics.MetricRegistryImpl$RegisteredMeters.registerMeter(MetricRegistryImpl.java:172)
at io.opencensus.implcore.metrics.MetricRegistryImpl$RegisteredMeters.access$200(MetricRegistryImpl.java:161)
at io.opencensus.implcore.metrics.MetricRegistryImpl.addDerivedLongGauge(MetricRegistryImpl.java:88)
at com.google.cloud.spanner.SessionPool.initMetricsCollection(SessionPool.java:2309)
at com.google.cloud.spanner.SessionPool.(SessionPool.java:1845)
at com.google.cloud.spanner.SessionPool.createPool(SessionPool.java:1822)
at com.google.cloud.spanner.SessionPool.createPool(SessionPool.java:1781)
at com.google.cloud.spanner.SpannerImpl.getDatabaseClient(SpannerImpl.java:225)
at java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)
at org.springframework.cloud.gcp.data.spanner.core.admin.CachingComposingSupplier.get(CachingComposingSupplier.java:52)
... 114 frames truncated
Describe the solution you'd like
I would like to see support to at least specify the metrics prefix when creating Database Client Bean using com.google.cloud.spanner.SpannerImpl#getDatabaseClient. That would resolve multiple databases issue and make the library support without sacrificing the metrics completely.
Describe alternatives you've considered
Temporary solution is to completely remove the Opencensus Impl library from maven dependencies in the runtime
or
Disable configuring multiple databases in spanner client and connect to only one database at a time.
Any Feedback on the above issue or improving this feature request is appreciated.
The text was updated successfully, but these errors were encountered: