GoogleCloudPlatform / GoogleCloudPlatform/cloud-sql-jdbc-socket-factory
Add support for GraalVM
- Dominant language
- Java
- Stars
- 255
- Forks
- 117
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 4
Description
## Question
How may I connect to CloudSQL via Cloud Run using a native binary with graalvm?
(I tried Quarkus and couldn't get it working with native binary, but it worked with JVM.)
I got stuck with the following stacktrace:
```
2020-03-20T23:00:41.791444ZGET5003.15 KB7 msChrome 80 https://api-/job
2020-03-20T23:05:27.302460Z2020-03-20 23:05:27,302 INFO [com.goo.clo.sql.cor.CoreSocketFactory] (Agroal_20652326221) Connecting to Cloud SQL instance [xxxx:europe-north1:xxxx] via unix socket.
2020-03-20T23:05:27.303618Z2020-03-20 23:05:27,302 WARN [io.agr.pool] (Agroal_20652326221) Datasource '': Something unusual has occurred to cause the driver to fail. Please report this exception.
2020-03-20T23:05:27.303661Z2020-03-20 23:05:27,302 WARN [org.hib.eng.jdb.spi.SqlExceptionHelper] (executor-thread-1) SQL Error: 0, SQLState: 99999
2020-03-20T23:05:27.303672Z2020-03-20 23:05:27,302 ERROR [org.hib.eng.jdb.spi.SqlExceptionHelper] (executor-thread-1) Something unusual has occurred to cause the driver to fail. Please report this exception.
2020-03-20T23:05:27.303688Z2020-03-20 23:05:27,303 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-1) HTTP Request to /job failed, error id: 0c84d8d4-28d1-4859-92ad-55559034e0a3-6: org.jboss.resteasy.spi.UnhandledException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
2020-03-20T23:05:27.303699Z at org.jboss.resteasy.core.ExceptionHandler.handleApplicationException(ExceptionHandler.java:106)
2020-03-20T23:05:27.303710Z at org.jboss.resteasy.core.ExceptionHandler.handleException(ExceptionHandler.java:372)
2020-03-20T23:05:27.303721Z at org.jboss.resteasy.core.SynchronousDispatcher.writeException(SynchronousDispatcher.java:209)
2020-03-20T23:05:27.303732Z at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
2020-03-20T23:05:27.303743Z at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
2020-03-20T23:05:27.303754Z at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
2020-03-20T23:05:27.303765Z at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
2020-03-20T23:05:27.303773Z at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
2020-03-20T23:05:27.303781Z at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
2020-03-20T23:05:27.303790Z at io.quarkus.resteasy.runtime.standalone.RequestDispatcher.service(RequestDispatcher.java:73)
2020-03-20T23:05:27.303802Z at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.dispatch(VertxRequestHandler.java:120)
2020-03-20T23:05:27.303812Z at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler.access$000(VertxRequestHandler.java:36)
2020-03-20T23:05:27.303819Z at io.quarkus.resteasy.runtime.standalone.VertxRequestHandler$1.run(VertxRequestHandler.java:85)
2020-03-20T23:05:27.303828Z at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
2020-03-20T23:05:27.303837Z at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2011)
2020-03-20T23:05:27.303847Z at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1535)
2020-03-20T23:05:27.303859Z at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1426)
2020-03-20T23:05:27.303869Z at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:29)
2020-03-20T23:05:27.303877Z at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:29)
2020-03-20T23:05:27.303886Z at java.lang.Thread.run(Thread.java:834)
2020-03-20T23:05:27.303896Z at org.jboss.threads.JBossThread.run(JBossThread.java:479)
2020-03-20T23:05:27.303904Z at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:497)
2020-03-20T23:05:27.303911Z at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
2020-03-20T23:05:27.303921ZCaused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
2020-03-20T23:05:27.303929Z at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
2020-03-20T23:05:27.303939Z at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1535)
2020-03-20T23:05:27.303950Z at org.hibernate.query.Query.getResultList(Query.java:165)
2020-03-20T23:05:27.303959Z at io.quarkus.hibernate.orm.panache.runtime.PanacheQueryImpl.list(PanacheQueryImpl.java:137)
2020-03-20T23:05:27.303968Z at io.quarkus.hibernate.orm.panache.runtime.JpaOperations.listAll(JpaOperations.java:340)
2020-03-20T23:05:27.303976Z at no.frivillig.entity.Job.listAll(Job.java)
2020-03-20T23:05:27.303983Z at no.frivillig.resources.JobResource.listJobs(JobResource.java:40)
2020-03-20T23:05:27.303991Z at java.lang.reflect.Method.invoke(Method.java:566)
2020-03-20T23:05:27.304Z at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:151)
2020-03-20T23:05:27.304008Z at org.jboss.resteasy.core.MethodInjectorImpl.lambda$invoke$3(MethodInjectorImpl.java:122)
2020-03-20T23:05:27.304018Z at java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:680)
2020-03-20T23:05:27.304028Z at java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658)
2020-03-20T23:05:27.304037Z at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2094)
2020-03-20T23:05:27.304094Z at java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:143)
2020-03-20T23:05:27.304105Z at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:122)
2020-03-20T23:05:27.304115Z at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:594)
2020-03-20T23:05:27.304126Z at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:468)
2020-03-20T23:05:27.304137Z at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:421)
2020-03-20T23:05:27.304151Z at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
2020-03-20T23:05:27.304162Z at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:423)
2020-03-20T23:05:27.304172Z at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:391)
2020-03-20T23:05:27.304184Z at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invoke$1(ResourceMethodInvoker.java:365)
2020-03-20T23:05:27.304196Z at java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1106)
2020-03-20T23:05:27.304206Z at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2235)
2020-03-20T23:05:27.304216Z at java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:143)
2020-03-20T23:05:27.304226Z at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:365)
2020-03-20T23:05:27.304238Z at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:477)
2020-03-20T23:05:27.304247Z ... 19 more
2020-03-20T23:05:27.304256ZCaused by: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
2020-03-20T23:05:27.304266Z at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
2020-03-20T23:05:27.304274Z at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
2020-03-20T23:05:27.304284Z at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
2020-03-20T23:05:27.304297Z at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:107)
2020-03-20T23:05:27.304307Z at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:134)
2020-03-20T23:05:27.304316Z at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.connection(StatementPreparerImpl.java:50)
2020-03-20T23:05:27.304324Z at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:149)
2020-03-20T23:05:27.304334Z at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:176)
2020-03-20T23:05:27.304346Z at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:151)
2020-03-20T23:05:27.304384Z at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:2104)
2020-03-20T23:05:27.304393Z at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2034)
2020-03-20T23:05:27.304403Z at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2012)
2020-03-20T23:05:27.304412Z at org.hibernate.loader.Loader.doQuery(Loader.java:953)
2020-03-20T23:05:27.304421Z at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
2020-03-20T23:05:27.304429Z at org.hibernate.loader.Loader.doList(Loader.java:2815)
2020-03-20T23:05:27.304437Z at org.hibernate.loader.Loader.doList(Loader.java:2797)
2020-03-20T23:05:27.304467Z at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2629)
2020-03-20T23:05:27.304475Z at org.hibernate.loader.Loader.list(Loader.java:2624)
2020-03-20T23:05:27.304482Z at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:506)
2020-03-20T23:05:27.304490Z at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:396)
2020-03-20T23:05:27.304499Z at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:219)
2020-03-20T23:05:27.304508Z at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1396)
2020-03-20T23:05:27.304516Z at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1558)
2020-03-20T23:05:27.304524Z at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1526)
2020-03-20T23:05:27.304531Z ... 44 more
2020-03-20T23:05:27.304540ZCaused by: org.postgresql.util.PSQLException: Something unusual has occurred to cause the driver to fail. Please report this exception.
2020-03-20T23:05:27.304548Z at org.postgresql.Driver.connect(Driver.java:281)
2020-03-20T23:05:27.304557Z at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:200)
2020-03-20T23:05:27.304565Z at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:390)
2020-03-20T23:05:27.304572Z at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:372)
2020-03-20T23:05:27.304580Z at java.util.concurrent.FutureTask.run(FutureTask.java:264)
2020-03-20T23:05:27.304588Z at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:65)
2020-03-20T23:05:27.304596Z at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1126)
2020-03-20T23:05:27.304605Z at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
2020-03-20T23:05:27.304612Z at java.lang.Thread.run(Thread.java:834)
2020-03-20T23:05:27.304619Z ... 2 more
2020-03-20T23:05:27.304627ZCaused by: java.lang.RuntimeException: Could not load platform constants for ProtocolFamily
2020-03-20T23:05:27.304636Z at jnr.constants.platform.ConstantResolver.getConstants(ConstantResolver.java:227)
2020-03-20T23:05:27.304644Z at jnr.constants.platform.ConstantResolver.lookupAndCacheConstant(ConstantResolver.java:128)
2020-03-20T23:05:27.304651Z at jnr.constants.platform.ConstantResolver.getConstant(ConstantResolver.java:116)
2020-03-20T23:05:27.304676Z at jnr.constants.platform.ConstantResolver.longValue(ConstantResolver.java:179)
2020-03-20T23:05:27.304684Z at jnr.constants.platform.ProtocolFamily.intValue(ProtocolFamily.java:48)
2020-03-20T23:05:27.304691Z at jnr.unixsocket.SockAddrUnix.setFamily(SockAddrUnix.java:55)
2020-03-20T23:05:27.304699Z at jnr.unixsocket.UnixSocketAddress.(UnixSocketAddress.java:48)
2020-03-20T23:05:27.304733Z at com.google.cloud.sql.core.CoreSocketFactory.connect(CoreSocketFactory.java:179)
2020-03-20T23:05:27.304746Z at com.google.cloud.sql.postgres.SocketFactory.createSocket(SocketFactory.java:71)
2020-03-20T23:05:27.304756Z at org.postgresql.core.PGStream.(PGStream.java:67)
2020-03-20T23:05:27.304764Z at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:91)
2020-03-20T23:05:27.304771Z at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
2020-03-20T23:05:27.304780Z at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
2020-03-20T23:05:27.304788Z at org.postgresql.jdbc.PgConnection.(PgConnection.java:211)
2020-03-20T23:05:27.304796Z at org.postgresql.Driver.makeConnection(Driver.java:458)
2020-03-20T23:05:27.304804Z at org.postgresql.Driver.connect(Driver.java:260)
2020-03-20T23:05:27.304811Z ... 10 more
```
## Additional Context
https://github.com/quarkusio/quarkus/pull/6634
https://github.com/quarkusio/quarkus/pull/6634#issuecomment-603997307
Contributor guide
Assessment
This issue has not been assessed yet.