From 0e039c647328d51e59b0c110c756b6bdf3398f4a Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 23 Sep 2026 12:39:29 +0000
Subject: [PATCH] [#1071] Wrap the sources of the large values PDBStorageTest writes, so that four copies of a 63 MB value are not live at once (#1072)

---
 opendj-server-legacy/src/test/java/org/opends/server/backends/pdb/PDBStorageTest.java |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/pdb/PDBStorageTest.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/pdb/PDBStorageTest.java
index 9bcbbb2..c52dd07 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/pdb/PDBStorageTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/pdb/PDBStorageTest.java
@@ -140,6 +140,14 @@
     storage.open(AccessMode.READ_WRITE);
   }
 
+  /**
+   * The sources are wrapped rather than copied: a value on its way into Persistit is copied twice more -
+   * {@code toByteArray()} and the value buffer of the exchange, which doubles up to 64 MB - so with a copy
+   * here as well the 63 MB value had four copies of itself live at once, on top of the buffer pool and the
+   * server: about 310 MB left after a collection, in a JVM of 512 MB, which one CI leg ran out of. Wrapped,
+   * about 165 MB. The three values stay in one transaction on purpose: the value buffer the 32 MB one
+   * grew fits the 63 MB one without growing again.
+   */
   @Test
   public void testCanAddLargeValues() throws Exception
   {
@@ -151,10 +159,10 @@
       public void run(WriteableTransaction txn) throws Exception
       {
         txn.openTree(treeName, true);
-        txn.put(treeName, valueOfUtf8("4mb"), valueOfBytes(new byte[4 * MB]));
-        txn.put(treeName, valueOfUtf8("32mb"), valueOfBytes(new byte[32 * MB]));
+        txn.put(treeName, valueOfUtf8("4mb"), wrap(new byte[4 * MB]));
+        txn.put(treeName, valueOfUtf8("32mb"), wrap(new byte[32 * MB]));
         // 64Mb is the maximum allowed for value size. But Persistit has header reducing the payload.
-        txn.put(treeName, valueOfUtf8("64mb"), valueOfBytes(new byte[63 * MB]));
+        txn.put(treeName, valueOfUtf8("64mb"), wrap(new byte[63 * MB]));
       }
     });
   }

--
Gitblit v1.10.0