From 4cee71bfa980931c4c74f29f8cea8e53b3b96480 Mon Sep 17 00:00:00 2001
From: pgamba <pgamba@localhost>
Date: Tue, 02 Oct 2007 09:08:20 +0000
Subject: [PATCH] Fix for #2356 - Unexpected generation ID error when replication enabled over empty suffix

---
 opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
index 3f3649e..7327666 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/plugin/ReplicationDomain.java
@@ -179,7 +179,9 @@
   private int maxSendQueue = 0;
   private int maxReceiveDelay = 0;
   private int maxSendDelay = 0;
+
   private long generationId = -1;
+  private boolean generationIdSavedStatus = false;
   private long rejectedGenerationId = -1;
   private boolean requestedResetSinceLastStart = false;
 
@@ -1049,6 +1051,11 @@
           waitingAckMsgs.put(curChangeNumber, msg);
         }
       }
+
+      if (generationIdSavedStatus != true)
+      {
+        this.saveGenerationId(generationId);
+      }
     }
     else if (!op.isSynchronizationOperation())
     {
@@ -2344,15 +2351,23 @@
     op.run();
 
     ResultCode result = op.getResultCode();
-    if ((result != ResultCode.SUCCESS) && (result != ResultCode.NO_SUCH_OBJECT))
+    if (result != ResultCode.SUCCESS)
     {
-      // The case where the backend is empty (NO_SUCH_OBJECT)
-      // is not an error case.
-      Message message = ERR_UPDATING_GENERATION_ID.get(
-                          op.getResultCode().getResultCodeName() + " " +
-                          op.getErrorMessage(),
-                          baseDN.toString());
-      logError(message);
+      generationIdSavedStatus = false;
+      if (result != ResultCode.NO_SUCH_OBJECT)
+      {
+        // The case where the backend is empty (NO_SUCH_OBJECT)
+        // is not an error case.
+        Message message = ERR_UPDATING_GENERATION_ID.get(
+            op.getResultCode().getResultCodeName() + " " +
+            op.getErrorMessage(),
+            baseDN.toString());
+        logError(message);
+      }
+    }
+    else
+    {
+      generationIdSavedStatus = true;
     }
     return result;
   }
@@ -2463,6 +2478,7 @@
     }
     else
     {
+      generationIdSavedStatus = true;
       if (debugEnabled())
         TRACER.debugInfo(
             "Generation ID successfully read from domain base DN=" + baseDN +

--
Gitblit v1.10.0