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

Jean-Noel Rouvignac
04.55.2013 2173fe6484daebf086de4eeed092db474758d094
OPENDJ-1190 (CR-2523) Under rare circumstances the DS replication recovery thread (RSUpdater) can spin


This change is linked to the misbehaving RSUpdater thread which (wrongly):
- could be started multiple times
- would not shutdown willingly when the server is shutting down
- would try to look for replay operations in the future



LDAPReplicationDomain.java:
In buildAndPublishMissingChanges(), only exit the loop when the currentStartCSN is newer than now (instead of the incorrect currentStartCSN + 10s).

HistoricalCsnOrderingTest.java:
Code cleanup.
2 files modified
46 ■■■■■ changed files
opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java 2 ●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java 44 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -4468,7 +4468,7 @@
          if (fakeOp.getCSN().isNewerThan(endCSN) // sanity check
              || !state.cover(fakeOp.getCSN())
              // do not look for replay operations in the future
              || endCSN.isNewerThan(now()))
              || currentStartCSN.isNewerThan(now()))
          {
            break;
          }
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/HistoricalCsnOrderingTest.java
@@ -87,8 +87,7 @@
   * Check the basic comparator on the HistoricalCsnOrderingMatchingRule
   */
  @Test()
  public void basicRuleTest()
  throws Exception
  public void basicRuleTest() throws Exception
  {
    // Creates a rule
    HistoricalCsnOrderingMatchingRule r =
@@ -97,17 +96,12 @@
    CSN del1 = new CSN(1,  0,  1);
    CSN del2 = new CSN(1,  1,  1);
    ByteString v1 = ByteString.valueOf("a"+":"+del1.toString());
    ByteString v2 = ByteString.valueOf("a"+":"+del2.toString());
    ByteString v1 = ByteString.valueOf("a" + ":" + del1);
    ByteString v2 = ByteString.valueOf("a" + ":" + del2);
    int cmp = r.compareValues(v1, v1);
    assertTrue(cmp == 0);
    cmp = r.compareValues(v1, v2);
    assertTrue(cmp == -1);
    cmp = r.compareValues(v2, v1);
    assertTrue(cmp == 1);
    assertEquals(r.compareValues(v1, v1), 0);
    assertEquals(r.compareValues(v1, v2), -1);
    assertEquals(r.compareValues(v2, v1), 1);
  }
  /**
@@ -116,8 +110,7 @@
   * informations.
   */
  @Test()
  public void buildAndPublishMissingChangesOneEntryTest()
  throws Exception
  public void buildAndPublishMissingChangesOneEntryTest() throws Exception
  {
    final int serverId = 123;
    final DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
@@ -129,7 +122,7 @@
    try
    {
      long startTime = TimeThread.getTime();
      final DN dn1 = DN.decode("cn=test1," + baseDN.toString());
      final DN dn1 = DN.decode("cn=test1," + baseDN);
    final AttributeType histType =
      DirectoryServer.getAttributeType(EntryHistorical.HISTORICAL_ATTRIBUTE_NAME);
@@ -138,7 +131,7 @@
    // Add the first test entry.
    TestCaseUtils.addEntry(
        "dn: cn=test1," + baseDN.toString(),
        "dn: cn=test1," + baseDN,
        "displayname: Test1",
        "objectClass: top",
        "objectClass: person",
@@ -150,10 +143,10 @@
    // Perform a first modification to update the historical attribute
    int resultCode = TestCaseUtils.applyModifications(false,
        "dn: cn=test1," + baseDN.toString(),
        "dn: cn=test1," + baseDN,
        "changetype: modify",
        "add: description",
    "description: foo");
        "description: foo");
    assertEquals(resultCode, 0);
    // Read the entry back to get its historical and included CSN
@@ -170,10 +163,10 @@
    // Perform a 2nd modification to update the hist attribute with
    // a second value
    resultCode = TestCaseUtils.applyModifications(false,
        "dn: cn=test1," + baseDN.toString(),
        "dn: cn=test1," + baseDN,
        "changetype: modify",
        "add: description",
    "description: bar");
        "description: bar");
    assertEquals(resultCode, 0);
    Entry entry2 = DirectoryServer.getEntry(dn1);
@@ -182,7 +175,7 @@
    for (AttributeValue av : attrs2.get(0)) {
      logError(Message.raw(Category.SYNC, Severity.INFORMATION,
          "Second historical value:" + av.getValue().toString()));
          "Second historical value:" + av.getValue()));
    }
    LinkedList<ReplicationMsg> opList = new LinkedList<ReplicationMsg>();
@@ -221,8 +214,7 @@
   * informations.
   */
  @Test()
  public void buildAndPublishMissingChangesSeveralEntriesTest()
  throws Exception
  public void buildAndPublishMissingChangesSeveralEntriesTest() throws Exception
  {
    final DN baseDN = DN.decode(TEST_ROOT_DN_STRING);
    TestCaseUtils.initializeTestBackend(true);
@@ -237,9 +229,9 @@
    "Starting replication test : changesCmpTest"));
    // Add 3 entries.
    DN dnTest1 = DN.decode("cn=test1," + baseDN.toString());
    DN dnTest2 = DN.decode("cn=test2," + baseDN.toString());
    DN dnTest3 = DN.decode("cn=test3," + baseDN.toString());
    DN dnTest1 = DN.decode("cn=test1," + baseDN);
    DN dnTest2 = DN.decode("cn=test2," + baseDN);
    DN dnTest3 = DN.decode("cn=test3," + baseDN);
    TestCaseUtils.addEntry(
        "dn: " + dnTest3,
        "displayname: Test1",