From add86d3c7c047215f886c51e2b29a4c7f1e86c0c Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Thu, 03 Sep 2026 08:21:14 +0000
Subject: [PATCH] [#877] Bound a statement of the JDBC backend by the class of the work it belongs to (#882)

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java
index 72bbded..af0f312 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/ID2Entry.java
@@ -382,7 +382,11 @@
   {
     // Make sure the tree is there and readable, even if the storage is READ_ONLY.
     // Would be nice if there were a better way...
-    try (final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName()))
+    // Bulk: the first batch of a cursor carries no seek predicate, so this is a walk of the whole
+    // tree as far as the storage is concerned, and it runs on every open of the backend. A bound
+    // meant for an entry read would keep a large backend from opening at all on an engine where
+    // such a batch is not a step along an index.
+    try (final Cursor<ByteString, ByteString> cursor = txn.openBulkCursor(getName()))
     {
       cursor.next();
     }
@@ -498,6 +502,12 @@
 
   /**
    * Check that a record entry exists in the entry tree.
+   * <p>
+   * Bulk, like the walk it belongs to: {@code VerifyJob.iterateID2ChildrenCount()} is its one
+   * caller and asks this once per record of the children count tree, inside a cursor over the
+   * whole of it. Read as a client operation those would put the bound of an entry read over a
+   * job nobody is waiting on, once per record - the same hazard the walk around them was given
+   * {@link ReadableTransaction#openBulkCursor(TreeName)} for (#877).
    *
    * @param txn a non null transaction
    * @param entryID The entry ID which forms the key.
@@ -508,7 +518,7 @@
   {
     checkNotNull(txn, "txn must not be null");
     checkNotNull(entryID, "entryID must not be null");
-    try(final Cursor<ByteString, ByteString> cursor = txn.openCursor(getName())) {
+    try(final Cursor<ByteString, ByteString> cursor = txn.openBulkCursor(getName())) {
       return cursor.positionToKey(entryID.toByteString());
     }
   }

--
Gitblit v1.10.0