mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
25.49.2015 14ba2a5582a448b3de3cc1eb789ff572cd62520d
Fix deadlock in JE Storage when running unit tests

Deadlock happens because EntryContainer.clear() calls JEStorage.deleteTree() on the state index
and then calls Index.setTrusted(true) for attribute and vlv indexes (which tries to open the state index) in the same transaction.
A workaround is to remove the call to Index.setTrusted(true) since it is not neccessary (see DefaultIndex constructor)

EntryContainer.java:
In clear(), removed the calls to Index.setTrusted(true).

JEStorage.java:
In deleteTree(), catch and swallow DatabaseNotFoundException. This is acceptable because it actually means what we want to do is already done.
2 files modified
8 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/JEStorage.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/JEStorage.java
@@ -521,6 +521,10 @@
      }
      catch (DatabaseNotFoundException e)
      {
        // This is fine: end result is what we wanted
      }
      catch (DatabaseException e)
      {
        throw new StorageRuntimeException(e);
      }
    }
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -2508,10 +2508,6 @@
          for (Tree tree : listTrees())
          {
            tree.delete(txn);
            if (tree instanceof Index)
            {
              ((Index) tree).setTrusted(txn, true);
            }
          }
        }
      });