Skip to content

HBASE-30320 TestMemStoreLAB#testLABChunkQueue OOM on fast hardware due to unbounded off-pool chunk allocation - #8533

Open
Umeshkumar9414 wants to merge 1 commit into
apache:masterfrom
Umeshkumar9414:HBASE-30320
Open

HBASE-30320 TestMemStoreLAB#testLABChunkQueue OOM on fast hardware due to unbounded off-pool chunk allocation#8533
Umeshkumar9414 wants to merge 1 commit into
apache:masterfrom
Umeshkumar9414:HBASE-30320

Conversation

@Umeshkumar9414

Copy link
Copy Markdown
Contributor

Summary

TestMemStoreLAB#testLABChunkQueue OOMs on machines with fast memory subsystems (e.g. Apple Silicon) even with large heap sizes (12GB+).

Root Cause: The test spawns 10 threads allocating 256KB chunks in a tight loop for a fixed 1-second window. Once the ChunkCreator pool reaches maxCount, subsequent allocations use unbounded off-pool chunk creation. All chunks remain live until mslab.close() is called after the threads stop. On fast hardware (~5,000 iterations/thread/sec), this creates ~12.5GB in 1 second, exceeding heap. On slower x86 CI machines (~700 iter/thread/sec), only ~1.7GB is created, fitting within the default 2.2GB surefire heap.

Fix: Add a memory guard — before each copyCellInto, check heap usage via ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() and stop allocating if used memory exceeds 80% of max heap. The 1-second time window is preserved; threads exit early only on memory-constrained JVMs.

  • Before: OOM with any heap < 13GB on Apple Silicon
  • After: Passes with 4GB heap on all hardware

Test plan

  • Verified TestMemStoreLAB (all 5 tests) passes with -Dsurefire.Xmx=4g on Apple Silicon
  • Verified at heap sizes 4g, 6g, 8g, 10g, 12g — all pass after fix (all failed before)
  • Verified chunk-recycling assertion still validates correctly (test semantics unchanged)
  • Same vulnerable code exists in branch-2, branch-2.5, branch-2.6, and master

…e 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant