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/tools/dsreplication/ReplicationCliMain.java |   49 +++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
index f80511a..495a11e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -5149,6 +5149,9 @@
       filter.addBaseDNsToSearch(uData.getBaseDNs());
     }
     ServerDescriptor server = createStandalone(conn, filter);
+    Set<DN> suffixesToDisable = uData.disableAll()
+        ? getConfiguredReplicationBaseDNs(conn)
+        : new HashSet<>(uData.getBaseDNs());
 
     ADSContext adsCtx = new ADSContext(conn);
 
@@ -5364,15 +5367,8 @@
       }
     }
 
-    Set<DN> suffixesToDisable;
-    if (uData.disableAll())
+    if (!uData.disableAll())
     {
-      suffixesToDisable = findAllReplicatedSuffixDNs(server.getReplicas());
-    }
-    else
-    {
-      suffixesToDisable = new HashSet<>(uData.getBaseDNs());
-
       if (disableAllBaseDns &&
           (disableReplicationServer || !server.isReplicationServer()))
       {
@@ -7149,6 +7145,43 @@
   }
 
   /**
+   * Reads configured domains directly: a domain base DN can be below a backend's base DN
+   * and will not appear in the server descriptor's replicas.
+   */
+  private Set<DN> getConfiguredReplicationBaseDNs(ConnectionWrapper conn) throws ReplicationCliException
+  {
+    try
+    {
+      final ReplicationSynchronizationProviderCfgClient sync;
+      try
+      {
+        sync = getMultimasterSynchronization(conn);
+      }
+      catch (ManagedObjectNotFoundException e)
+      {
+        return Collections.emptySet();
+      }
+
+      final Set<DN> baseDNs = new LinkedHashSet<>();
+      final String[] domainNames = sync.listReplicationDomains();
+      if (domainNames != null)
+      {
+        for (String domainName : domainNames)
+        {
+          baseDNs.add(sync.getReplicationDomain(domainName).getBaseDN());
+        }
+      }
+      return baseDNs;
+    }
+    catch (OperationsException | LdapException e)
+    {
+      throw new ReplicationCliException(
+          ERR_REPLICATION_ERROR_READING_CONFIGURATION.get(conn.getHostPort(), e.getMessage()),
+          ERROR_READING_CONFIGURATION, e);
+    }
+  }
+
+  /**
    * Deletes a replication domain in a server for a given base DN (disable
    * replication of the base DN).
    * @param conn the connection to the server.

--
Gitblit v1.10.0