googleapis / java-spanner-jdbc

Apache License 2.0
64 stars 48 forks source link

JDBC Connectivity Issue with OpenJDK 17 #1687

Open wise-coders opened 3 months ago

wise-coders commented 3 months ago

Connecting to Google Cloud Spanner I got the exception below. I use the 2.20.1 single jar with dependencies and OpenJdk17.0.11. Which could be the reason?

com.google.cloud.spanner.SpannerException: UNAVAILABLE: com.google.cloud.spanner.SpannerException: UNAVAILABLE: com.google.api.gax.rpc.UnavailableException: io.grpc.StatusRuntimeException: UNAVAILABLE: io exception Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0] at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerExceptionPreformatted(SpannerExceptionFactory.java:291) at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerExceptionPreformatted(SpannerExceptionFactory.java:297) at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:61) at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:181) at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:110) at com.google.cloud.spanner.SpannerExceptionFactory.asSpannerException(SpannerExceptionFactory.java:100) at com.google.cloud.spanner.SessionPool.getDialect(SessionPool.java:3002) at com.google.cloud.spanner.DatabaseClientImpl.getDialect(DatabaseClientImpl.java:77) at com.google.cloud.spanner.connection.ConnectionImpl.getDialect(ConnectionImpl.java:450) at com.google.cloud.spanner.jdbc.AbstractJdbcConnection.getDialect(AbstractJdbcConnection.java:89) at com.google.cloud.spanner.jdbc.JdbcDatabaseMetaData.getSchemas(JdbcDatabaseMetaData.java:1565) at com.google.cloud.spanner.jdbc.JdbcDatabaseMetaData.getSchemas(JdbcDatabaseMetaData.java:776) at com.wisecoders.dbs.dbms.Dbms.listSchemasAndCatalogs(Dbms.java:294) at com.wisecoders.dbs.dbms.Dbms.loadSchemaMapping(Dbms.java:281) at com.wisecoders.dbs.dbms.connect.fx.FxTestConnectivityTask.a(FxTestConnectivityTask.java:52) at com.wisecoders.dbs.dbms.connect.fx.FxTestConnectivityTask.call(FxTestConnectivityTask.java:19) java.util.concurrent.ExecutionException: com.google.cloud.spanner.SpannerException: UNAVAILABLE: com.google.api.gax.rpc.UnavailableException: io.grpc.StatusRuntimeException: UNAVAILABLE: io exception Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0] at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:594) at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:445) at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:118) at com.google.cloud.spanner.SessionPool.getDialect(SessionPool.java:3000) at com.google.cloud.spanner.DatabaseClientImpl.getDialect(DatabaseClientImpl.java:77) at com.google.cloud.spanner.connection.ConnectionImpl.getDialect(ConnectionImpl.java:450) at com.google.cloud.spanner.jdbc.AbstractJdbcConnection.getDialect(AbstractJdbcConnection.java:89) at com.google.cloud.spanner.jdbc.JdbcDatabaseMetaData.getSchemas(JdbcDatabaseMetaData.java:1565) at com.google.cloud.spanner.jdbc.JdbcDatabaseMetaData.getSchemas(JdbcDatabaseMetaData.java:776) at com.wisecoders.dbs.dbms.Dbms.listSchemasAndCatalogs(Dbms.java:294) at com.wisecoders.dbs.dbms.Dbms.loadSchemaMapping(Dbms.java:281) at com.wisecoders.dbs.dbms.connect.fx.FxTestConnectivityTask.a(FxTestConnectivityTask.java:52) at com.wisecoders.dbs.dbms.connect.fx.FxTestConnectivityTask.call(FxTestConnectivityTask.java:19) com.google.cloud.spanner.SpannerException: UNAVAILABLE: com.google.api.gax.rpc.UnavailableException: io.grpc.StatusRuntimeException: UNAVAILABLE: io exception Channel Pipeline: [SslHandler#0, ProtocolNegotiators$ClientTlsHandler#0, WriteBufferingAndExceptionHandler#0, DefaultChannelPipeline$TailContext#0] at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerExceptionPreformatted(SpannerExceptionFactory.java:291) at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerExceptionPreformatted(SpannerExceptionFactory.java:297) at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:170) at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:110) at com.google.cloud.spanner.SessionPool$SessionConsumerImpl.onSessionCreateFailure(SessionPool.java:3826) at com.google.cloud.spanner.SessionClient$BatchCreateSessionsRunnable.run(SessionClient.java:139) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:840)

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please include as much information as possible:

Environment details

  1. Specify the API at the beginning of the title. For example, "BigQuery: ..."). General, Core, and Other are also allowed as types
  2. OS type and version:
  3. Java version:
  4. version(s):

Steps to reproduce

  1. ?
  2. ?

Code example

// example

Stack trace

Any relevant stacktrace here.

External references such as API reference guides

Any additional information below

Following these steps guarantees the quickest resolution possible.

Thanks!

olavloite commented 3 months ago

@wise-coders Is there a specific reason that you are using the single-jar-with-dependencies? And what is the further setup of your system? Are you providing the driver to some third-party tool that requires a jar-with-dependencies, or are you adding the jar-with-dependencies to your own project? If it is the latter, then I would recommend not using the single-jar-with-dependencies.

The most likely reason for a problem like this is a class conflict in the application. For example if the single-jar-with-dependencies contains a class that is also on the class path of other dependencies of the application, then unpredictable errors can occur. That can again affect the working of the gRPC libraries, including even errors like this.

I'll try to take a look at the single-jar-with-dependencies build in this project to ensure it works as-is, but combining it with any other application is risky, as you can easily run into dependency conflicts.

wise-coders commented 3 months ago

We are using the single-jar-with-dependencies inside DbSchema, a Google Cloud Spanner database designer. You can download and test it for free. I don't think it's a conflict with other libraries, as the previous releases worked fine, and we continue using the same libraries.

olavloite commented 3 months ago

We are using the single-jar-with-dependencies inside DbSchema, a Google Cloud Spanner database designer. You can download and test it for free.

Thanks for the additional info. That clarifies why you are using the single-jar (although even in a case like this, I would generally recommend not using a single-jar, but dynamically load all dependencies. DBeaver for example does this for the JDBC drivers it supports.)

I don't think it's a conflict with other libraries, as the previous releases worked fine, and we continue using the same libraries.

Yes, but the Spanner JDBC driver does not :-)

There is a constant stream of updates to the gRPC libraries that are used by the JDBC driver, and my suspicion is that this error comes from one of those.

olavloite commented 2 months ago

@wise-coders I've added an integration test that verifies that the single-jar-with-dependencies and its shaded cousin work in the simplest possible setup (that is; an application with no other dependencies). Those tests succeed, meaning that there does not appear to be a generic problem with the single-jar.

Would it be possible for you to either:

  1. Create a reproduction scenario based on this test, for example by trying to add the dependencies that are used by your application to that test to see if it then fails?
  2. OR share the complete dependency tree that your application uses in this issue, so I can try to see if I can get the same behavior?
olavloite commented 1 month ago

@wise-coders Any chance you can provide a minimal reproduction case for this?