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

Yannick Lecaillez
11.45.2015 f2f95003dffb483fd470e679ea55dde9f81b36d9
OPENDJ-2543: ChangelogException while doing modrate on PDB instance.

Some cursor continue to be referenced in the openCursors list while they
are actually closed. This caused IOException during head log file
rotation when disableOpenedCursorsOnHead() tried to get state of those
closed and still referenced cursors.
By acquiring shared-lock on cursor.close() we ensure that the close()
and the removal of the cursor from the openedCursors lists are performed
atomically.
1 files modified
12 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/Log.java 12 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/Log.java
@@ -774,6 +774,7 @@
  /**
   * Abort all cursors opened on the provided log file.
   * @GuardedBy("exclusiveLock")
   */
  private void abortCursorsOpenOnLogFile(LogFile<K, V> logFile)
  {
@@ -1079,6 +1080,7 @@
    }
  }
  /** @GuardedBy("exclusiveLock") */
  private void abortAllOpenCursors() throws ChangelogException
  {
    for (AbortableLogCursor<K, V> cursor : openCursors)
@@ -1539,9 +1541,19 @@
    @Override
    public void close()
    {
      // Lock is needed here to ensure that log cursor cannot be closed while still referenced in the cursor list.
      // Removing the cursor before the close is not enough due to the CopyOnWrite nature of the cursor list.
      log.sharedLock.lock();
      try
      {
      delegate.close();
      log.unregisterCursor(this);
    }
      finally
      {
        log.sharedLock.unlock();
      }
    }
    @Override
    public boolean positionTo(K key, KeyMatchingStrategy matchStrategy, PositionStrategy positionStrategy)