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

Yannick Lecaillez
14.51.2015 621bbbda7419eace24a2590c43cc531e30185c80
OPENDJ-2543: ChangelogException while doing modrate on PDB instance.

Removed deadlock when next() has the object-lock and try to get the log
's shared-lock actually held by the abortAllCursor() doing an abort()
which is waiting for the object lock held by the caller of next().
1 files modified
26 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/Log.java 26 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/Log.java
@@ -1527,15 +1527,24 @@
    }
    @Override
    public synchronized boolean next() throws ChangelogException
    public boolean next() throws ChangelogException
    {
      if (mustAbort)
      // This lock is needed to ensure that abort() is atomic.
      log.sharedLock.lock();
      try
      {
        delegate.close();
        delegate = new AbortedLogCursor<>(log.getPath());
        mustAbort = false;
        if (mustAbort)
        {
          delegate.close();
          delegate = new AbortedLogCursor<>(log.getPath());
          mustAbort = false;
        }
        return delegate.next();
      }
      return delegate.next();
      finally
      {
        log.sharedLock.unlock();
      }
    }
    @Override
@@ -1565,10 +1574,9 @@
    /**
     * Aborts this cursor. Once aborted, a cursor throws an
     * AbortedChangelogCursorException if it is used.
     * <p>
     * This method is called only when log.exclusiveLock has been acquired.
     * @GuardedBy("exclusiveLock")
     */
    synchronized void abort()
    void abort()
    {
      mustAbort = true;
    }