Skip to content
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

SNOW-755767: snowflake-jdbc driver fails with JDK >= 16 #589

Closed
sreev opened this issue Sep 28, 2021 · 50 comments
Closed

SNOW-755767: snowflake-jdbc driver fails with JDK >= 16 #589

sreev opened this issue Sep 28, 2021 · 50 comments
Assignees
Labels
status-triage_done Initial triage done, will be further handled by the driver team

Comments

@sreev
Copy link

sreev commented Sep 28, 2021

env:
mac v11.6
intellij
openjdk17
snowflake-driver v3.13.8 jar from maven repo

stack trace:
Exception in thread "main" net.snowflake.client.jdbc.SnowflakeSQLLoggedException: JDBC driver internal error: Fail to retrieve row count for first arrow chunk: sun.misc.Unsafe or java.nio.DirectByteBuffer.<init>(long, int) not available. at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.setFirstChunkRowCountForArrow(SnowflakeResultSetSerializableV1.java:1061) at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.create(SnowflakeResultSetSerializableV1.java:550) at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.create(SnowflakeResultSetSerializableV1.java:467) at net.snowflake.client.core.SFResultSetFactory.getResultSet(SFResultSetFactory.java:29) at net.snowflake.client.core.SFStatement.executeQueryInternal(SFStatement.java:219) at net.snowflake.client.core.SFStatement.executeQuery(SFStatement.java:134) at net.snowflake.client.core.SFStatement.execute(SFStatement.java:743) at net.snowflake.client.core.SFStatement.execute(SFStatement.java:639) at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQueryInternal(SnowflakeStatementV1.java:238) at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQuery(SnowflakeStatementV1.java:133)

workaround:
Change jdk17 to jdk11.

@fprochazka
Copy link

fprochazka commented Oct 14, 2021

I have the same problem.

Ubuntu 20.04.3 LTS
openjdk 17 2021-09-14
OpenJDK Runtime Environment Temurin-17+35 (build 17+35)
OpenJDK 64-Bit Server VM Temurin-17+35 (build 17+35, mixed mode, sharing)

Downgrading to JDK 16 "fixes" the problem

@benveniste
Copy link

Adding the JVM argument: --add-opens java.base/java.nio=ALL-UNNAMED seems to solve the problem.

@iamzafar
Copy link

Is there a solution without downgrading to JDK 16?

@iamzafar
Copy link

@sfc-gh-kdama @sfc-gh-mknister Could you please look at this issue? It seems like #682 solves that. Releasing this would be really appreciated because our snowflake apps are failing with JDK17. Is there any chance to include this fix in the next following release?

@wise-coders
Copy link

I also vote for fixing it. For me, the driver fails even with the add-opens flag.

@iamzafar
Copy link

I wasn't able to create the ticket but found one that's already been reported #533

@vkopichenko
Copy link

vkopichenko commented May 13, 2022

It looks that ARROW-12747 was finally resolved three days ago in version 8.0.0.
I was able to build snowflake-jdbc project with shaded arrow 8.0.0 and it became usable under Java 17.
Still had to add --add-opens java.base/java.nio=ALL-UNNAMED, though.
Let's hope that we'll get soon a new snowflake-jdbc:3.13.19 release with upgraded arrow that will be finally compatible with Java 17. =)

@iamzafar
Copy link

Adding a VM argument is not a good way to do this. I'd use it if it's really necessary. Otherwise, I avoid using VM arguments in production during the runtime because VM arguments are a black box to me.

@vkopichenko
Copy link

The issue can be marked as resolved since 3.13.19 snowflake-jdbc driver version.

@flamber
Copy link

flamber commented May 31, 2022

I haven't tested, but are you sure @vkopichenko ?
Snowflake 3.13.19 is using Arrow 7: https://github.com/snowflakedb/snowflake-jdbc/blob/v3.13.19/pom.xml#L40
But the fix is only included in Arrow 8: https://issues.apache.org/jira/browse/ARROW-12747

@vkopichenko
Copy link

Oh. It seems I got deceived by long-awaited eager expectations.
Sorry for spammy false alarm.
Will have to train attentiveness and patience a bit longer. )

@sfc-gh-wfateem
Copy link
Collaborator

This should be addressed in #1017

@datanrd
Copy link

datanrd commented Jul 8, 2022

After upgrading to 3.13.20 we are still seeing errors with JDK 17

java.lang.ExceptionInInitializerError: null
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.UnsafeAllocationManager.<clinit>(UnsafeAllocationManager.java:27)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.DefaultAllocationManagerFactory.<clinit>(DefaultAllocationManagerFactory.java:26)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:375)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.DefaultAllocationManagerOption.getFactory(DefaultAllocationManagerOption.java:111)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.DefaultAllocationManagerOption.getDefaultAllocationManagerFactory(DefaultAllocationManagerOption.java:101)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.BaseAllocator$Config.getAllocationManagerFactory(BaseAllocator.java:735)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.ImmutableConfig.access$801(ImmutableConfig.java:24)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.ImmutableConfig$InitShim.getAllocationManagerFactory(ImmutableConfig.java:83)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.ImmutableConfig.<init>(ImmutableConfig.java:47)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.ImmutableConfig.<init>(ImmutableConfig.java:24)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.ImmutableConfig$Builder.build(ImmutableConfig.java:485)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.BaseAllocator.<clinit>(BaseAllocator.java:63)
	at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.create(SnowflakeResultSetSerializableV1.java:560)
	at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.create(SnowflakeResultSetSerializableV1.java:479)
	at net.snowflake.client.core.SFResultSetFactory.getResultSet(SFResultSetFactory.java:29)
	at net.snowflake.client.core.SFStatement.executeQueryInternal(SFStatement.java:220)
	at net.snowflake.client.core.SFStatement.executeQuery(SFStatement.java:135)
	at net.snowflake.client.core.SFStatement.execute(SFStatement.java:768)
	at net.snowflake.client.core.SFStatement.execute(SFStatement.java:678)
	at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQueryInternal(SnowflakeStatementV1.java:238)
	at net.snowflake.client.jdbc.SnowflakePreparedStatementV1.executeQuery(SnowflakePreparedStatementV1.java:117)
	at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
	at io.opentracing.contrib.jdbc.TracingPreparedStatement.executeQuery(TracingPreparedStatement.java:62)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.opentracing.contrib.common.WrapperProxy$1.invoke(WrapperProxy.java:73)
	at jdk.proxy2/jdk.proxy2.$Proxy264.executeQuery(Unknown Source)
	at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:722)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:651)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:713)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:744)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:757)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:815)
	at com.reece.platform.products.pdw.repository.DataWarehouseRepository.getChangedProducts(DataWarehouseRepository.java:46)
	at com.reece.platform.products.pdw.repository.DataWarehouseRepository$$FastClassBySpringCGLIB$$36bc6300.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
	at com.reece.platform.products.pdw.repository.DataWarehouseRepository$$EnhancerBySpringCGLIB$$3c90c8c9.getChangedProducts(<generated>)
	at com.reece.platform.products.search.CreateIndexService.loadChangedProducts(CreateIndexService.java:145)
	at com.reece.platform.products.search.CreateIndexService.updateCurrentEngine(CreateIndexService.java:99)
	at com.reece.platform.products.controller.JobsController.updateIndex(JobsController.java:31)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:920)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:684)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at io.opentracing.contrib.web.servlet.filter.TracingFilter.doFilter(TracingFilter.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.RuntimeException: Failed to initialize MemoryUtil.
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.util.MemoryUtil.<clinit>(MemoryUtil.java:139)
	... 108 common frames omitted
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field long java.nio.Buffer.address accessible: module java.base does not "opens java.nio" to unnamed module @5a4aa2f2
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
	at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.util.MemoryUtil.<clinit>(MemoryUtil.java:87)
	... 108 common frames omitted

...

net.snowflake.client.jdbc.SnowflakeSQLException: JDBC driver internal error: exception creating result java.lang.ExceptionInInitializerError at net.snowflake.client.jdbc.internal.apache.arrow.memory.UnsafeAllocationManager.<clinit>(UnsafeAllocationManager.java:27).
	at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQueryInternal(SnowflakeStatementV1.java:245)
	at net.snowflake.client.jdbc.SnowflakePreparedStatementV1.executeQuery(SnowflakePreparedStatementV1.java:117)
	at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
	at io.opentracing.contrib.jdbc.TracingPreparedStatement.executeQuery(TracingPreparedStatement.java:62)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at io.opentracing.contrib.common.WrapperProxy$1.invoke(WrapperProxy.java:73)
	at jdk.proxy2/jdk.proxy2.$Proxy264.executeQuery(Unknown Source)
	at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:722)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:651)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:713)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:744)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:757)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:815)
	at com.reece.platform.products.pdw.repository.DataWarehouseRepository.getChangedProducts(DataWarehouseRepository.java:46)
	at com.reece.platform.products.pdw.repository.DataWarehouseRepository$$FastClassBySpringCGLIB$$36bc6300.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:753)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:698)
	at com.reece.platform.products.pdw.repository.DataWarehouseRepository$$EnhancerBySpringCGLIB$$3c90c8c9.getChangedProducts(<generated>)
	at com.reece.platform.products.search.CreateIndexService.loadChangedProducts(CreateIndexService.java:145)
	at com.reece.platform.products.search.CreateIndexService.updateCurrentEngine(CreateIndexService.java:99)
	at com.reece.platform.products.controller.JobsController.updateIndex(JobsController.java:31)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
	at org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:920)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:684)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:96)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at io.opentracing.contrib.web.servlet.filter.TracingFilter.doFilter(TracingFilter.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:889)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:833)

@sfc-gh-wfateem
Copy link
Collaborator

Confirmed that the problem still occurs with Apache Arrow v8.0. We'll need to look into this and see what's happening here.

@mdiskin
Copy link

mdiskin commented Aug 18, 2022

Confirmed that the problem still occurs with Apache Arrow v8.0. We'll need to look into this and see what's happening here.

https://arrow.apache.org/release/9.0.0.html was released August 3rd does this correct the issue?

@sfc-gh-wfateem
Copy link
Collaborator

@mdiskin it won't unfortunately.

The issue really requires all developers to plan to migrate to modules, otherwise, so long as any project (whether that's Arrow, Snowflake-JDBC, or Netty) uses reflection then you will always see these warnings/errors in JDK 9 and above. These problems manifested themselves as just warnings but then turned into errors once the JDK turned on strong encapsulation by default starting with JDK 16.

The issue described here is directly caused by Apache Arrow Memory, and the same code exists in v9.0 that leverages the sun.misc package.

Here's the output of the jdeps command when run against some of the classes involved in the issue in the Apache Arrow project:

❯ jdeps -jdkinternals ./memory/memory-unsafe/target/classes/org/apache/arrow/memory/UnsafeAllocationManager.class
UnsafeAllocationManager.class -> /Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/rt.jar
   org.apache.arrow.memory.UnsafeAllocationManager (UnsafeAllocationManager.class)
      -> sun.misc.Unsafe                                    JDK internal API (rt.jar)

Warning: JDK internal APIs are unsupported and private to JDK implementation that are
subject to be removed or changed incompatibly and could break your application.
Please modify your code to eliminate dependency on any JDK internal APIs.
For the most recent update on JDK internal API replacements, please check:
https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool

JDK Internal API                         Suggested Replacement
----------------                         ---------------------
sun.misc.Unsafe                          See http://openjdk.java.net/jeps/260

...

❯ jdeps -jdkinternals ./memory/memory-core/target/classes/org/apache/arrow/memory/util/MemoryUtil.class
MemoryUtil.class -> /Library/Java/JavaVirtualMachines/jdk1.8.0_271.jdk/Contents/Home/jre/lib/rt.jar
   org.apache.arrow.memory.util.MemoryUtil (MemoryUtil.class)
      -> sun.misc.Unsafe                                    JDK internal API (rt.jar)

Warning: JDK internal APIs are unsupported and private to JDK implementation that are
subject to be removed or changed incompatibly and could break your application.
Please modify your code to eliminate dependency on any JDK internal APIs.
For the most recent update on JDK internal API replacements, please check:
https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool

JDK Internal API                         Suggested Replacement
----------------                         ---------------------
sun.misc.Unsafe                          See http://openjdk.java.net/jeps/260

So the real solution is to use the following guide to migrate all the projects:
Migrating to JDK 9

As you can imagine, that will probably take time. I see Arrow started working on this. Even though the JIRA was closed as "incomplete," there is a PR that's still in progress:
https://issues.apache.org/jira/browse/ARROW-16328

@LiamAttardcol
Copy link

I still face the same issue. JDK 17, Spring Boot 3 and Snowflake JDBC version 3.13.28. Thanks

@sfc-gh-wfateem sfc-gh-wfateem changed the title SNOW-755767: snowflake-jdbc driver fails with openjdk 17 SNOW-755767: snowflake-jdbc driver fails with JDK >= 16 Dec 11, 2023
@hrithikrajDN
Copy link

&JDBC_QUERY_RESULT_FORMAT=JSON

This worked for me.
Thanks.

@paoliniluis
Copy link

@sfc-gh-wfateem Unless I'm mistaken, Arrow is already compatible with JDK 8+ according to their documentation https://arrow.apache.org/docs/java/install.html#id3.

Although, there are items still open in their issue tracker, most important one is apache/arrow#38915, which has only one open issue apache/arrow#39000

Is that correct? that last item needs to be closed to be able to have a snowflake jdbc driver compatible with JDK 8+?

@paoliniluis
Copy link

Hi @sfc-gh-wfateem, sorry for being insistent, were you able to see my last comment? Thanks

@sfc-gh-wfateem
Copy link
Collaborator

@paoliniluis The problem is not compatibility with JDK 8+, the problem is with JDK 16 and onwards. Please refer to the KB article here.

All items in #38915 would need to be implemented including #39000 to address that issue highlighted in the KB article. Once it is implemented, we would need to then include that Arrow dependency in the Snowflake JDBC JAR.

I hope that addresses your question.

@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage_done Initial triage done, will be further handled by the driver team label Apr 26, 2024
@paoliniluis
Copy link

@sfc-gh-wfateem the Arrow team confirmed that they're not going to address the issue apache/arrow#39000 (comment), any plans to complete this?

@sfc-gh-wfateem
Copy link
Collaborator

@paoliniluis do you mean for us to step in and make the necessary changes in Arrow? If that's what you mean then no, we don't have plans to do that. If Arrow can't address the issue directly, then there's not much we can do on our end, I'm afraid.

@paoliniluis
Copy link

@sfc-gh-wfateem thanks for confirming, I guess there are a lot of projects waiting on this to happen. If this will never happen I would encourage your team to close this issue and document the workaround mentioned above so many projects can move forward with this

@sfc-gh-wfateem
Copy link
Collaborator

@paoliniluis yes, that probably makes more sense at this point. I personally wasn't aware that Arrow decided against the change until you brought it up. Thanks for sharing that with us.

@sfc-gh-wfateem
Copy link
Collaborator

To wrap this up, we went into detail explaining the nature of the issue in the following article:
JDBC Driver Compatibility Issue With JDK 16 and Later

The workaround for JDK 16 is to add the following JVM argument:
-Djdk.module.illegalAccess=permit

For JDK 17 and higher, you need to add the following Java option:
--add-opens java.base/java.nio=ALL-UNNAMED

At the time of this comment, Arrow had decided that they weren't going to make the necessary changes needed to unblock this issue: apache/arrow#39000 (comment)

If Arrow comes back and fixes this then we can revisit this issue. In the meantime, we're going to move forward with closing this issue as there isn't much more that can be done other than providing everyone with the workarounds mentioned.

@alexanderankin
Copy link

alexanderankin commented Jun 28, 2024

are there any jdbc drivers for snowflake not using the arrow library?

workaround for spring:

spring:
  datasource:
    hikari:
      connection-init-sql: ALTER SESSION SET JDBC_QUERY_RESULT_FORMAT='JSON'

@axk283
Copy link

axk283 commented Aug 1, 2024

are there any jdbc drivers for snowflake not using the arrow library?

workaround for spring:

spring:
  datasource:
    hikari:
      connection-init-sql: ALTER SESSION SET JDBC_QUERY_RESULT_FORMAT='JSON'

Its works for me jdk21 and snowflake 3.13.29

@grepwood
Copy link

grepwood commented Sep 9, 2024

@sfc-gh-dszmolka please avoid marking unresolved issues as "completed" and "closed" because this is misleading.

@sfc-gh-dszmolka
Copy link
Contributor

not sure why you got the impression i marked with completed or closed @grepwood but my colleague provided a pretty good description why he closed it for now. Please see #589 (comment)

@sfc-gh-dszmolka sfc-gh-dszmolka removed In-Progress Issue to track for internal purpose bug labels Sep 9, 2024
@grepwood
Copy link

grepwood commented Sep 9, 2024

@sfc-gh-dszmolka sorry, tagged the wrong person. As for the reason why I had the impression this is fixed:
image
If that doesn't say "closed" and "completed" then I might have to get myself checked.

I don't think this is anywhere near being fixed because Arrow won't fix it: apache/arrow#39000 (comment)

@alexanderankin
Copy link

Would this project accept a PR that replaces Arrow as the implementation? If snowflake driver starts using a library, there is a decent chance that adoption will follow and the fork/alternative would succeed. I would be embarrassed, as the arrow project to lose market share to a competing library, but something has got to give; some people can only be reasoned with by avoidance.

@sfc-gh-wfateem sfc-gh-wfateem reopened this Sep 9, 2024
@sfc-gh-wfateem sfc-gh-wfateem closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
@sfc-gh-wfateem
Copy link
Collaborator

sfc-gh-wfateem commented Sep 9, 2024

@grepwood sorry for the confusion. I rectified the status now.
We have to close the issue because leaving it open also gives the impression that there's actually something that can be done here concerning the Arrow project, and there isn't. If you look through the history of this issue, you'll notice that we're at the phase where comments are becoming redundant. This is why I provided the latest status and our position on the whole problem in the following comment:
#589 (comment)

@alexanderankin It's a bit more complicated than merely changing the Arrow dependency in the JDBC driver. You have to make a change at the backend as well because the data the driver downloads is in Arrow format, so changing that on the client's side won't fix the problem.

@alexanderankin
Copy link

alexanderankin commented Sep 9, 2024

@sfc-gh-wfateem yes to clarify, I am suggesting that someone (not snowflake, willing volunteers, if any) fork the arrow library and remove the erroneous parts which are not compatible with modern java anymore (using internal APIs or whatever).

The question to snowflake-jdbc maintainers is - would you be willing to try using that new library (again - not asking for fixes - asking for likelyhood of accepting a PR - which would replace the dependency to a new one, and update any import statements e.g. from import arrow.pkg.format.ArrowParser to import correct.arrow.pkg.format.ArrowParser)

@sfc-gh-wfateem
Copy link
Collaborator

@alexanderankin I see. If you or someone else is willing to take on that task, wouldn't it make more sense to just contribute that to Arrow directly rather than create a new project?

There are reasons why the Arrow team tabled this. It's not really an easy issue to address. You would basically need to replace Netty as well as a dependency for Arrow, or go and make changes in Netty.

Let's say you manage to fork it and address these problems, I am skeptical we'll want to replace the dependency to use that forked one unless we know it's going to be properly maintained and thorough testing takes place to ensure that these changes won't cause performance regressions (and any other issues).

@grepwood
Copy link

grepwood commented Sep 9, 2024

So if we would like to fix this issue in the way that end users would prefer it would be, we should perhaps concentrate our efforts on Netty?

@sfc-gh-wfateem
Copy link
Collaborator

@grepwood If you're interested in working on this, I would start by having a discussion with the Arrow team here. They would be the most knowledgeable people to talk to about what needs to take place to address the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet