From 400fb2694641b05e53217d3c742a6e49e3a254c6 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Sun, 29 Nov 2026 07:16:47 +0000
Subject: [PATCH] [#1208] Preserve replication history during scaling, recovery and shutdown (#1282)
---
opendj-server-legacy/src/main/java/org/opends/server/replication/server/MessageHandler.java | 30 +++++++++++++++++++++++++++++-
1 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/MessageHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/MessageHandler.java
index f79dbce..1d00b54 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/MessageHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/MessageHandler.java
@@ -178,6 +178,19 @@
}
/**
+ * Returns the newest update of this replica deliberately not handed to this queue.
+ * RS handlers use domain-wide peer receipts so a newly registered handler sees
+ * updates whose publication began before it registered.
+ *
+ * @param serverId the replica which produced the update
+ * @return its newest unqueued update, or {@code null} when none is known
+ */
+ protected CSN getLatestUnqueuedUpdate(int serverId)
+ {
+ return null;
+ }
+
+ /**
* Whether the consumer has every change the queue may lack which the changelog still holds - see
* {@link #queueLacksUpTo} and {@link #consumerLacksFromTheChangelog(CSN, ServerState)}.
* <p>
@@ -263,7 +276,11 @@
{
replicationServerDomain = replicationServer.getReplicationServerDomain(
baseDN, true);
- if (waitConnections)
+ // Let a bootstrapping domain learn its generation and topology before accepting
+ // a DS. A domain already serving a DS must be able to accept another while the
+ // connect thread is waiting for a peer RS.
+ if (waitConnections && (replicationServerDomain.getGenerationId() <= 0
+ || replicationServerDomain.getConnectedDSs().isEmpty()))
{
replicationServer.waitConnections();
}
@@ -525,6 +542,17 @@
*/
continue;
}
+ // A replica may have written through a peer since this queue was last used.
+ // Its next direct write must not advance our cursor past that unqueued prefix.
+ // Other replicas keep following normally: an RS does not relay idle peer traffic.
+ final CSN next = msgQueue.first().getCSN();
+ final CSN unqueued = getLatestUnqueuedUpdate(next.getServerId());
+ if (unqueued != null && !serverState.cover(next) && !serverState.cover(unqueued)
+ && consumerLacksFromTheChangelog(unqueued, replicationServerDomain.getLatestServerState()))
+ {
+ following = false;
+ continue;
+ }
UpdateMsg msg = msgQueue.removeFirst();
if (updateServerState(msg))
{
--
Gitblit v1.10.0