Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-5408

RocksDB initialization can fail with an UnsatisfiedLinkError in the presence of multiple classloaders

    Details

      Description

      When the RocksDB is loaded from different ClassLoaders (for example because it is in the user code jar, or loaded dynamically in tests) it may fail with an "java.lang.UnsatisfiedLinkError: Native Library /path/to/temp/dir/librocksdbjni-linux64.so already loaded in another classloader.

      Apparently the JVM can handle multiple instances of the same JNI library being loaded in different class loaders, but not when coming from the same file path.

      This affects only version 1.2 onward, because from there we extract the JNI library into Flink's temp folders to make sure that it gets cleaned up for example by YARN when the application finishes. When giving a parent directory, RocksDB does not add a unique number sequence to the temp file name.

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user StephanEwen opened a pull request:

          https://github.com/apache/flink/pull/3060

          FLINK-5408 [RocksDB backend] Uniquify RocksDB JNI library path to avoid multiple classloader problem

          When the RocksDB is loaded from different ClassLoaders (for example because it is in the user code jar, or loaded dynamically in tests) it may fail with an
          ```
          java.lang.UnsatisfiedLinkError: Native Library /path/to/temp/dir/librocksdbjni-linux64.so already loaded in another classloader.
          ```

          Apparently the JVM can handle multiple instances of the same JNI library being loaded in different class loaders, but not when coming from the same file path.

          This makes sure the JNI lib path is unique to circumvent this.

          The test reflectively loads different versions of the class from different class loaders to validate that.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/StephanEwen/incubator-flink rdb_loading

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/flink/pull/3060.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #3060


          commit d5256a2e89004c436bc7943affaec16b91cdb56a
          Author: Stephan Ewen <sewen@apache.org>
          Date: 2017-01-04T23:18:13Z

          FLINK-5408 [RocksDB backend] Uniquify RocksDB JNI library path to avoid multiple classloader problem


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user StephanEwen opened a pull request: https://github.com/apache/flink/pull/3060 FLINK-5408 [RocksDB backend] Uniquify RocksDB JNI library path to avoid multiple classloader problem When the RocksDB is loaded from different ClassLoaders (for example because it is in the user code jar, or loaded dynamically in tests) it may fail with an ``` java.lang.UnsatisfiedLinkError: Native Library /path/to/temp/dir/librocksdbjni-linux64.so already loaded in another classloader. ``` Apparently the JVM can handle multiple instances of the same JNI library being loaded in different class loaders, but not when coming from the same file path. This makes sure the JNI lib path is unique to circumvent this. The test reflectively loads different versions of the class from different class loaders to validate that. You can merge this pull request into a Git repository by running: $ git pull https://github.com/StephanEwen/incubator-flink rdb_loading Alternatively you can review and apply these changes as the patch at: https://github.com/apache/flink/pull/3060.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #3060 commit d5256a2e89004c436bc7943affaec16b91cdb56a Author: Stephan Ewen <sewen@apache.org> Date: 2017-01-04T23:18:13Z FLINK-5408 [RocksDB backend] Uniquify RocksDB JNI library path to avoid multiple classloader problem
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user StephanEwen commented on the issue:

          https://github.com/apache/flink/pull/3060

          Since this is a crucial fix to stabilize the master, I will merge this in the near future...

          Show
          githubbot ASF GitHub Bot added a comment - Github user StephanEwen commented on the issue: https://github.com/apache/flink/pull/3060 Since this is a crucial fix to stabilize the master, I will merge this in the near future...
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user StephanEwen commented on the issue:

          https://github.com/apache/flink/pull/3060

          Manually merged in 3070ff9a6d9de47a4713d4b4952929f8c00043b1

          Show
          githubbot ASF GitHub Bot added a comment - Github user StephanEwen commented on the issue: https://github.com/apache/flink/pull/3060 Manually merged in 3070ff9a6d9de47a4713d4b4952929f8c00043b1
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user StephanEwen closed the pull request at:

          https://github.com/apache/flink/pull/3060

          Show
          githubbot ASF GitHub Bot added a comment - Github user StephanEwen closed the pull request at: https://github.com/apache/flink/pull/3060
          Hide
          StephanEwen Stephan Ewen added a comment -

          Fixed in

          • 1.2.0 via 91f9a1acaa899159a0d907528634bd246e6854b4
          • 1.3.0 via 3070ff9a6d9de47a4713d4b4952929f8c00043b1
          Show
          StephanEwen Stephan Ewen added a comment - Fixed in 1.2.0 via 91f9a1acaa899159a0d907528634bd246e6854b4 1.3.0 via 3070ff9a6d9de47a4713d4b4952929f8c00043b1

            People

            • Assignee:
              StephanEwen Stephan Ewen
              Reporter:
              StephanEwen Stephan Ewen
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development