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

Error when testing Snowflake JDBC on MacOS via GitHub Actions #39

Open
anthonysena opened this issue Jun 4, 2024 · 2 comments
Open

Comments

@anthonysena
Copy link

I'm not sure if this is the right place to log this but wanted to capture it somewhere since it was giving me trouble when attempting to test CohortGenerator across all of the DB platforms and OS combos. When running the Snowflake tests on MacOS I was getting the following error:

java.lang.ExceptionInInitializerError
	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:421)
	at java.base/java.lang.Class.forName(Class.java:412)
	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:577)
	at net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1.create(SnowflakeResultSetSerializableV1.java:489)
	at net.snowflake.client.core.SFResultSetFactory.getResultSet(SFResultSetFactory.java:29)
	at net.snowflake.client.core.SFStatement.executeQueryInternal(SFStatement.java:218)
	at net.snowflake.client.core.SFStatement.executeQuery(SFStatement.java:133)
	at net.snowflake.client.core.SFStatement.execute(SFStatement.java:746)
	at net.snowflake.client.core.SFStatement.execute(SFStatement.java:[656](https://github.com/OHDSI/CohortGenerator/actions/runs/9369160053/job/25792944215#step:14:657))
	at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQueryInternal(SnowflakeStatementV1.java:236)
	at net.snowflake.client.jdbc.SnowflakeStatementV1.executeQuery(SnowflakeStatementV1.java:131)
	at org.***.databaseConnector.BatchedQuery.<init>(BatchedQuery.java:134)
Caused by: java.lang.RuntimeException: Failed to initialize MemoryUtil.
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.util.MemoryUtil.<clinit>(MemoryUtil.java:139)
	... 24 more
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 @5[662](https://github.com/OHDSI/CohortGenerator/actions/runs/9369160053/job/25792944215#step:14:663)0197
	at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315)
	at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:183)
	at java.base/java.lang.reflect.Field.setAccessible(Field.java:177)
	at net.snowflake.client.jdbc.internal.apache.arrow.memory.util.MemoryUtil.<clinit>(MemoryUtil.java:87)
	... 24 more

When I reviewed the failure, I noted that by default GitHub Actions was using Java 21 which lead me to this article: https://community.snowflake.com/s/article/JDBC-Driver-Compatibility-Issue-With-JDK-16-and-Later. I tried to set the JDK options as described with no luck.

I wound up replacing this block of the .github/workflows/R_CMD_check_Hades.yaml from:

      - name: Reconfigure Java
        if: runner.os == 'macOS'
        run: R CMD javareconf

to:

      - name: Setup Java
        uses: actions/setup-java@v4
        with:
          distribution: 'corretto'
          java-version: '8'

which then resolved the issue.

@schuemie
Copy link
Member

schuemie commented Jun 6, 2024

Thanks for figuring this out Anthony!

The old block only had an effect on MacOS, but your new block specifies the Java version for all operating systems. Is that intentional?

@anthonysena
Copy link
Author

It was unintentional and actually caused me some problems. So the update should read:

      - name: Setup Java
        if: runner.os == 'macOS'
        uses: actions/setup-java@v4
        with:
          distribution: 'corretto'
          java-version: '8'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants