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

ludovicp
28.31.2010 420d0685be611af4544bcce545a380b9298c0d6a
Fix for issue #4514 and #4533. Resolved some possible lock contention in ReplicationServerDomain, resulting in errors in logs. 
3 files modified
44 ■■■■ changed files
opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java 9 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/DataServerHandler.java 7 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java 28 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -3632,12 +3632,21 @@
    }
    if (search.getResultCode() != ResultCode.SUCCESS)
    {
      if (search.getResultCode() == ResultCode.NO_SUCH_OBJECT)
      {
        // nothing initialized yet
        // don't log an error generationID will be computed.
      }
      else
      {
        //
      Message message = ERR_SEARCHING_GENERATION_ID.get(
          search.getResultCode().getResultCodeName() + " " +
          search.getErrorMessage(),
          baseDn.toString());
      logError(message);
    }
    }
    else
    {
      LinkedList<SearchResultEntry> result = search.getSearchEntries();
opends/src/server/org/opends/server/replication/server/DataServerHandler.java
@@ -142,8 +142,6 @@
          // method. This would lead to a reentrant lock which we do not want.
          // So simply close the session, this will make the hang up appear
          // after the reader thread that took the RSD lock realeases it.
          try
          {
            if (session != null)
            {
              // V4 protocol introduces a StopMsg to properly close the
@@ -158,11 +156,6 @@
                  // Anyway, going to close session, so nothing to do
                }
              }
              session.close();
            }
          } catch (IOException e)
          {
            // ignore
          }
          // NOT_CONNECTED_STATUS is the last one in RS session life: handler
opends/src/server/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -2110,11 +2110,14 @@
   *
   * @param generationId The new value of generationId.
   */
  synchronized public void initGenerationID(long generationId)
  public void initGenerationID(long generationId)
  {
    synchronized (generationIDLock)
  {
    this.generationId = generationId;
    this.generationIdSavedStatus = true;
  }
  }
  /**
   * Sets the provided value as the new in memory generationId.
@@ -2124,8 +2127,9 @@
   * @param savedStatus  The saved status of the generationId.
   * @return The old generation id
   */
  synchronized public long changeGenerationId(long generationId,
    boolean savedStatus)
  public long changeGenerationId(long generationId, boolean savedStatus)
  {
    synchronized (generationIDLock)
  {
    long oldGenerationId = this.generationId;
@@ -2137,9 +2141,9 @@
      this.generationId = generationId;
      this.generationIdSavedStatus = savedStatus;
    }
    return oldGenerationId;
  }
  }
  /**
   * Resets the generationID.
@@ -2564,10 +2568,11 @@
   * @return The monitor data.
   * @throws DirectoryException When an error occurs.
   */
  synchronized protected MonitorData computeMonitorData(
      boolean updateMonitorData)
  protected MonitorData computeMonitorData(boolean updateMonitorData)
    throws DirectoryException
  {
    synchronized (monitoringLock)
    {
    if (updateMonitorData)
    {
      // Update the monitorData of ALL domains if this was necessary.
@@ -2577,6 +2582,7 @@
    // Returns the monitorData of THIS domain
    return monitorData;
  }
  }
  /**
   * Start collecting global monitoring information for this
@@ -2859,6 +2865,16 @@
  private ReentrantLock lock = new ReentrantLock();
  /**
   * This lock is used to protect the monitoring computing.
   */
  private final Object monitoringLock = new Object();
  /**
   * This lock is used to protect the generationid variable.
   */
  private final Object generationIDLock = new Object();
  /**
   * Tests if the current thread has the lock on this domain.
   * @return True if the current thread has the lock.
   */