From bb6e7c58161ac441a9b9a68da5e765ea5a7942d5 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 09 Sep 2026 07:15:42 +0000
Subject: [PATCH] [#918] Record a ReplicaOfflineMsg as sent only when it really was published (#946)

---
 opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/LDAPReplicationDomain.java |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 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 423fc2b..ac15154 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
@@ -2105,7 +2105,21 @@
   public void publishReplicaOfflineMsg()
   {
     final CSN offlineCSN = pendingChanges.putReplicaOfflineMsg();
-    dsrsShutdownSync.replicaOfflineMsgSent(getBaseDN(), offlineCSN);
+    if (offlineCSN != null)
+    {
+      /*
+       * 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.
+       */
+      dsrsShutdownSync.replicaOfflineMsgSent(getBaseDN(), offlineCSN);
+    }
+    else if (logger.isTraceEnabled())
+    {
+      logger.trace("Replica " + getServerId() + " of domain baseDN=" + getBaseDN()
+          + " could not announce itself offline: a change which is still in flight holds"
+          + " the message back, and " + pendingChanges.size() + " change(s) are pending");
+    }
   }
 
   /**

--
Gitblit v1.10.0