apache / pinot

Apache Pinot - A realtime distributed OLAP datastore
https://pinot.apache.org/
Apache License 2.0
5.39k stars 1.26k forks source link

`mvn clean install` fail on Mac with M1 chip #10945

Closed mingmxu closed 1 month ago

mingmxu commented 1 year ago

When running mvn clean install on latest code, some unit tests(from module pinot-segment-spi, pinot-segment-local, pinot-core, ...), fail with error message like below:

java.lang.UnsatisfiedLinkError: 'long xerial.larray.impl.LArrayNative.mmap(long, int, long, long)'
        at xerial.larray.impl.LArrayNative.mmap(Native Method)
        at xerial.larray.mmap.MMapBuffer.<init>(MMapBuffer.java:94)
        at org.apache.pinot.segment.spi.memory.PinotNativeOrderLBuffer.mapFile(PinotNativeOrderLBuffer.java:49)
[ERROR] Failures: 
[ERROR]   PinotDefaultByteBufferTest>PinotDataBufferTest.testConstructors:294 » UnsatisfiedLink
[ERROR]   PinotLArrayByteBufferTest>PinotDataBufferTest.testConstructors:294 » UnsatisfiedLink
[ERROR]   PinotLArrayByteBufferTest>PinotDataBufferInstanceTestBase.testMapFileBE:140 » UnsatisfiedLink
[ERROR]   PinotLArrayByteBufferTest>PinotDataBufferInstanceTestBase.testMapFileLE:153 » UnsatisfiedLink
[ERROR]   PinotLArrayByteBufferTest>PinotDataBufferInstanceTestBase.testMultipleClose:78 » UnsatisfiedLink
[ERROR]   PinotLArrayByteBufferTest>PinotDataBufferTest.testPinotNativeOrderBuffer:90->PinotDataBufferTest.testOrderBuffer:79 » UnsatisfiedLink
[ERROR]   PinotLArrayByteBufferTest>PinotDataBufferTest.testPinotNativeOrderBufferReadWriteFile:136->PinotDataBufferTest.testPinotBufferReadWriteFile:120 » UnsatisfiedLink
[ERROR]   PinotLArrayByteBufferTest>PinotDataBufferTest.testPinotNonNativeOrderBuffer:96->PinotDataBufferTest.testOrderBuffer:79 » UnsatisfiedLink
[ERROR]   PinotLArrayByteBufferTest>PinotDataBufferTest.testPinotNonNativeOrderBufferReadWriteFile:142->PinotDataBufferTest.testPinotBufferReadWriteFile:120 » UnsatisfiedLink
[ERROR]   PinotLArrayByteBufferTest>PinotDataBufferTest.testViewAndToDirectByteBuffer:205 » UnsatisfiedLink
[INFO] 
[ERROR] Tests run: 128, Failures: 10, Errors: 0, Skipped: 0

I suspect it's related with xerial/larray which doesn't mention MacM1/2 support. Should create a mac_m1_m2 profile to exclude these tests?

larray-mmap (MMapBuffer and LArray.mmap) uses JNI and is available for the following major CPU architectures:

Windows (32/64-bit)
Linux (i368, amd64 (Intel 64-bit), arm, armhf)
Mac OSX (Intel 64bit)

cc @mayankshriv

Jackie-Jiang commented 1 year ago

@gortiz I remember you encountered similar issue?

gortiz commented 1 year ago

Hi @mingmxu. You have to options:

  1. Use Rosetta to run maven, as explained in Pinot doc. Remember that Rosetta must be enabled in your shell (see this or this). You can verify if it is the case by executing mvn --version, which prints the arch it is using. It should say amd64. When Rosetta is disabled, it prints arch: "aarch64". You may also need to install a amd64 JVM.
  2. Run maven with Java 17, which will not use LArray but the new buffer library that doesn't use JNI. Again, to know which version are you using, just do mvn --version, which also indicates the JVM.
mingmxu commented 1 year ago

Thanks @gortiz for the suggestions. I don't find a amd64 JVM, would try the approach later.

Java17 helps to block the LArray JNI failure, there's another clp-ffi in pinot-core module, cc @kirkrodrigues who might have some context.

gortiz commented 1 year ago

I usually use sdkman to install different JDKs. In case you are using it, you need to enable Rosetta in sdkman as well in order to install the amd64 JDK. This article explains how to do use sdkman to install JDKs in different architectures: https://itnext.io/how-to-install-x86-and-arm-jdks-on-the-mac-m1-apple-silicon-using-sdkman-872a5adc050d.

kirkrodrigues commented 1 year ago

Hi @mingmxu, clp-ffi doesn't have aarch64 support yet. I will try and add it this weekend and submit a PR.

ankitsultana commented 2 months ago

@kirkrodrigues : if it is not a lot of work for you folks, can you try to add this support?

mvn tests don't work on M1/M2 systems because of this.

kirkrodrigues commented 2 months ago

Sorry, things keep getting reprioritized. We did create a build with the new binaries, just need to finish testing it on different platforms. Will release a new clp-ffi version in the next couple days and then PR to Pinot.

gortiz commented 1 month ago

I don't find a amd64 JVM, would try the approach later.

You can try to use sdkman or download it from temurin web page.

Assuming you don't plan to use CLP (which is not supported in ARM), you can also run with Java 17/21 and just skip these tests.

We are just working on #13648 which adds profiles that skip these tests by default and #13639 which disables larray by default.

Anyway, as a developer that uses M1, I have to say you should get used to these issues and how to use Rosetta, because there are still some software that doesn't work with ARM processors.

gortiz commented 1 month ago

We have now Maven profiles for aarch64 (see https://github.com/apache/pinot/pull/13648) which disabled the CLP tests. Once we have the CLP binaries for aarch64 we can enable these tests again.

Should we close this issue as resolved?

ankitsultana commented 1 month ago

This worked for me finally! Thanks a lot folks!

Will close this. We can re-open if the issue still exists.