diff --git llap-server/src/java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java llap-server/src/java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java index 9e7a8dce64..341da252c4 100644 --- llap-server/src/java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java +++ llap-server/src/java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java @@ -331,6 +331,9 @@ public void allocateMultiple(MemoryBuffer[] dest, int size, BufferObjectFactory return; } + // Another thread might have allocated a new arena + arenaCount = getArenaCount(); + // We called reserveMemory so we know that there's memory waiting for us somewhere. // But that can mean that the reserved memory is fragmented thus unusable // or we have a common class of rare race conditions related to the order of locking/checking of @@ -453,6 +456,8 @@ public void allocateMultiple(MemoryBuffer[] dest, int size, BufferObjectFactory logOomErrorMessage(msg); throw new AllocatorOutOfMemoryException(msg); } + // Another thread might have allocated a new arena for us to check + arenaCount = getArenaCount(); ++discardsAttempt; } } finally { diff --git llap-server/src/test/org/apache/hadoop/hive/llap/cache/TestBuddyAllocator.java llap-server/src/test/org/apache/hadoop/hive/llap/cache/TestBuddyAllocator.java index 506d9d1648..8b3ffddd34 100644 --- llap-server/src/test/org/apache/hadoop/hive/llap/cache/TestBuddyAllocator.java +++ llap-server/src/test/org/apache/hadoop/hive/llap/cache/TestBuddyAllocator.java @@ -105,7 +105,7 @@ public void testSameSizes() throws Exception { allocSameSize(a, arenaCount * 2, allocLog2); } - /* HIVE-22286: Disabled test until HIVE-22175 is resolved @Test */ + @Test public void testMTT() { final int min = 3, max = 8, maxAlloc = 1 << max, allocsPerSize = 3; final BuddyAllocator a = new BuddyAllocator(isDirect, isMapped, 1 << min, maxAlloc,