From 600df926522919b63bfca2816ef9588b6f1c6e34 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Tue, 15 Sep 2026 17:09:57 +0000
Subject: [PATCH] [#950] Announce a ReplicaOfflineMsg before it is published, not after it may have been forwarded (#978)

---
 opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
index 989d0e5..0b87409 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java
@@ -828,7 +828,8 @@
      * The generator time is adjusted to the time of the last CSN received from
      * remote other servers.
      */
-    pendingChanges = new PendingChanges(getGenerator(), this);
+    pendingChanges = new PendingChanges(getGenerator(), this,
+        new ShutdownSyncAnnouncer(dsrsShutdownSync, getBaseDN()));
     remotePendingChanges = new RemotePendingChanges(getServerState());
 
     // listen for changes on the configuration
@@ -2271,17 +2272,13 @@
   public void publishReplicaOfflineMsg()
   {
     final CSN offlineCSN = pendingChanges.putReplicaOfflineMsg();
-    if (offlineCSN != null)
+    if (offlineCSN == null && logger.isTraceEnabled())
     {
       /*
-       * Only a message which really was published is announced: the shutdown of a collocated
-       * replication server waits for it to be forwarded, and would spend the whole grace
-       * period waiting for one which never reached the wire.
+       * The announcement itself is made where the message is published, so nothing has to be
+       * reported here: a message a change in flight held back was never announced, and the
+       * announcement of one the broker refused has been withdrawn.
        */
-      dsrsShutdownSync.replicaOfflineMsgSent(getBaseDN(), offlineCSN);
-    }
-    else if (logger.isTraceEnabled())
-    {
       logger.trace("Replica " + getServerId() + " of domain baseDN=" + getBaseDN()
           + " could not announce itself offline: the message was not published - a change which"
           + " is still in flight holds it back, or the broker had no session to write it to,"

--
Gitblit v1.10.0