OHDSI / Hades

Health Analytics Data-to-Evidence Suite (HADES): A collection of R packages for performing analytics against the Common Data Model.
https://ohdsi.github.io/Hades
Apache License 2.0
23 stars 12 forks source link

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

Open anthonysena opened 5 months ago

anthonysena commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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'