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

Fabio Pistolesi
17.01.2015 89183d52637336618123b78c1410381b7780d977
OPENDJ-2396 Replication: post-external-initialization generates an error in log

After online import or restore, replication startListenService() was being called twice, once from import handling and once from the callback registered by replication on backend changes.
While stopping the listener thread is idempotent, starting it was not, leading to contention by both threads.

Fix by forcing idempotency also when starting the listener thread and make sure idempotency also applie to the broker thread.
2 files modified
18 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationBroker.java 10 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationDomain.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationBroker.java
@@ -269,6 +269,10 @@
  {
    synchronized (startStopLock)
    {
      if (!shutdown)
      {
        return;
      }
      shutdown = false;
      this.rcvWindow = getMaxRcvWindow();
      connectAsDataServer();
@@ -2660,13 +2664,17 @@
  /** Stop the server. */
  public void stop()
  {
    if (logger.isTraceEnabled())
    if (logger.isTraceEnabled() && !shutdown)
    {
      debugInfo("is stopping and will close the connection to RS(" + getRsServerId() + ")");
    }
    synchronized (startStopLock)
    {
      if (shutdown)
      {
        return;
      }
      domain.publishReplicaOfflineMsg();
      shutdown = true;
      setConnectedRS(ConnectedRS.stopped());
opendj-server-legacy/src/main/java/org/opends/server/replication/service/ReplicationDomain.java
@@ -2942,8 +2942,12 @@
  {
    synchronized (sessionLock)
    {
      final String threadName = "Replica DS(" + getServerId()
          + ") listener for domain \"" + getBaseDN() + "\"";
      if (listenerThread != null)
      {
        return;
      }
      final String threadName = "Replica DS(" + getServerId() + ") listener for domain \"" + getBaseDN() + "\"";
      listenerThread = new DirectoryThread(new Runnable()
      {