From e193d73b6b8d893cebf46d0eb2ee9d3735b690f6 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Fri, 11 Sep 2026 13:07:27 +0000
Subject: [PATCH] [#967] Keep the bookkeeping of a domain whose base entry is missing out of its configuration entry (#972)

---
 opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java
index 6b5bba9..7b7bf70 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/PersistentServerState.java
@@ -303,24 +303,26 @@
   /**
    * Save the current values of this PersistentState object
    * in the appropriate entry of the database.
+   * <p>
+   * A base entry which is not in the backend - a suffix waiting to be initialized by an
+   * import - leaves this state unwritten until the entry appears. The state used to be
+   * written to the domain configuration entry instead, and must not be again: that write
+   * goes through the configuration backend, which holds its update lock while it calls
+   * every change listener of the entry back, and the domain is one of them -
+   * {@code LDAPReplicationDomain.applyConfigurationChange()} takes the very lock
+   * {@code disable()} holds while it calls this, so the two orders deadlock.
+   * <p>
+   * Nothing is lost by not writing it. A suffix whose base entry is missing holds no entry
+   * at all, so no change of this replica is in this state, and a change from another one
+   * can not be replayed into it either. The value a former version left on the
+   * configuration entry is still read back by {@link #loadState()}.
    *
    * @return a boolean indicating if the method was successful.
    */
   private boolean updateStateEntry()
   {
     // Generate a modify operation on the Server State baseDN Entry.
-    ResultCode result = runUpdateStateEntry(baseDN);
-    if (result == ResultCode.NO_SUCH_OBJECT)
-    {
-      // The base entry does not exist yet in the database or has been deleted,
-      // save the state to the config entry instead.
-      SearchResultEntry configEntry = searchConfigEntry();
-      if (configEntry != null)
-      {
-        result = runUpdateStateEntry(configEntry.getName());
-      }
-    }
-    return result == ResultCode.SUCCESS;
+    return runUpdateStateEntry(baseDN) == ResultCode.SUCCESS;
   }
 
   /**

--
Gitblit v1.10.0