Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-1964

Java binding crashes when sessions are closed in a different thread

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • WT2.7.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      The documentation for multithreading states that Sessions are allowed to be shared across threads, as long as access is synchronized so that the same handle isn't being operated on by more than one thread at a time. This seems like a useful semantic, so I tried creating a cache for sessions and it is working, except that when I close the session handles at the end of the program, it segfaults instead of closing gracefully. The attached file is a minimal test case that simply creates two sessions and then closes them in the main thread with connection.close().

      I don't fully understand what is going on, but based on googling around, it sounds like the problem is that the JNIEnv is specific to a single thread. The swig binding uses the JNIEnv of the thread that created the Session to close it - I think instead it must be the JNIEnv of the current thread that is doing the close.

        1. Example2.java
          1 kB
        2. Example.java
          0.9 kB

            Assignee:
            donald.anderson@mongodb.com Donald Anderson
            Reporter:
            grogers Greg Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: