From 36eb696d429633c9300e62c4d9aa908900f89793 Mon Sep 17 00:00:00 2001 From: Umeshkumar9414 <9414umeshkumar@gmail.com> Date: Thu, 6 Aug 2026 16:10:32 +0530 Subject: [PATCH] HBASE-30320 TestMemStoreLAB#testLABChunkQueue OOM on fast hardware due to unbounded off-pool chunk allocation Add a memory guard in testLABChunkQueue's allocation threads: before each copyCellInto call, check heap usage via ManagementFactory and stop allocating if used memory exceeds 80% of max heap. This prevents OOM on fast hardware (e.g. Apple Silicon) where threads can allocate ~12.5GB of 256KB chunks in the 1-second test window, while preserving the time-based test semantics. --- .../apache/hadoop/hbase/regionserver/TestMemStoreLAB.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreLAB.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreLAB.java index dbf8e4cbc891..427e39cfb3fa 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreLAB.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemStoreLAB.java @@ -329,12 +329,19 @@ public void testForceCopyOfBigCellInto() { private Thread getChunkQueueTestThread(final MemStoreLABImpl mslab, String threadName, ExtendedCell cellToCopyInto) { + // Reserve 20% of max heap as safety margin to prevent OOM on fast hardware where threads can + // allocate many GB of chunks within the 1-second test window. + final long maxMemory = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getMax(); + final long memoryLimit = (long) (maxMemory * 0.8); Thread thread = new Thread() { volatile boolean stopped = false; @Override public void run() { while (!stopped) { + if (ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() > memoryLimit) { + break; + } // keep triggering chunk retirement mslab.copyCellInto(cellToCopyInto); }