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

Valery Kharseko
3 hours ago 36d4af9bd7b9f0617f33fa5bb1db2aff574f14d7
[#924] Clear the disabled flag before a domain enables its session (#971)
1 files modified
35 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java 35 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -3954,10 +3954,39 @@
        return;
      }
      enableService();
      sessionGeneration++;
      /*
       * The flag is cleared before the session is started, where disable() sets it before
       * stopping one: enableService() ends with startListenService(), so the listener it
       * starts can list a delivery and hand it to a replay thread while this method is
       * still running. A replay thread which reads a flag that still says "disabled"
       * gives the change up at the top of its replay loop, and abandonReplay() does not
       * ask for it again - a domain on its way down owns its session - so the change is
       * left listed, uncommitted and owned by nobody. Nothing would replay it: the
       * replication server only sends it again over a session which is restarted, so this
       * domain's ServerState, and every change which depends on that one, would be held
       * back for as long as the session lives.
       */
      disabled = false;
      boolean started = false;
      try
      {
        enableService();
        sessionGeneration++;
        started = true;
      }
      finally
      {
        if (!started)
        {
          /*
           * The other half of the same invariant: a domain whose session could not be
           * started owns that session the way a disabled one does, so the flag goes back
           * where it was rather than leave the replay threads believing there is a session
           * of theirs to restart.
           */
          disabled = true;
        }
      }
    }
  }