From 724371370bdbff2b869530f1fe87fc69364212d7 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 23 Sep 2026 12:38:42 +0000
Subject: [PATCH] [#1067] Ask the memory quota whether an explicit db-cache-size fits instead of taking it (#1070)

---
 opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/ConfigurableEnvironment.java |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/ConfigurableEnvironment.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/ConfigurableEnvironment.java
index ab669e8..c364a19 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/ConfigurableEnvironment.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/ConfigurableEnvironment.java
@@ -403,11 +403,14 @@
         throw new ConfigException(ERR_CONFIG_JEB_CACHE_SIZE_TOO_SMALL.get(
             dbCacheSize, MemoryBudget.MIN_MAX_MEMORY_SIZE));
       }
+      // Asked, not taken: the storage this configuration is built for reserves the size itself and
+      // gives that reservation back when it closes. A size the quota cannot grant is only warned
+      // about - the open goes ahead without a reservation, and at startup nothing checks it earlier.
       MemoryQuota memoryQuota = DirectoryServer.getInstance().getServerContext().getMemoryQuota();
-      if (!memoryQuota.acquireMemory(dbCacheSize))
+      if (!memoryQuota.isMemoryAvailable(dbCacheSize))
       {
         logger.warn(ERR_BACKEND_CONFIG_CACHE_SIZE_GREATER_THAN_JVM_HEAP.get(
-            dbCacheSize, memoryQuota.getMaxMemory()));
+            dbCacheSize, memoryQuota.getAvailableMemory()));
       }
     }
   }

--
Gitblit v1.10.0