Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -459,20 +459,20 @@ public QueryMemoryReservationHandler(
@Override
public ListenableFuture<?> reserveMemory(String allocationTag, long delta, boolean enforceBroadcastMemoryLimit)
{
ListenableFuture<?> future = reserveMemoryFunction.apply(allocationTag, delta);
if (enforceBroadcastMemoryLimit) {
updateBroadcastMemoryFunction.accept(delta);
}
ListenableFuture<?> future = reserveMemoryFunction.apply(allocationTag, delta);
return future;
}

@Override
public boolean tryReserveMemory(String allocationTag, long delta, boolean enforceBroadcastMemoryLimit)
{
if (!tryReserveMemoryFunction.test(allocationTag, delta)) {
if (enforceBroadcastMemoryLimit && !tryUpdateBroadcastMemoryFunction.test(delta)) {
return false;
}
return !enforceBroadcastMemoryLimit || tryUpdateBroadcastMemoryFunction.test(delta);
return tryReserveMemoryFunction.test(allocationTag, delta);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,39 @@ public void testChecksTotalMemoryOnUserMemoryAllocation()
}
}

@Test
public void testChecksTotalMemoryOnUserMemoryAllocationWithBroadcastEnable()
{
MemoryPool generalPool = new MemoryPool(GENERAL_POOL, new DataSize(10, BYTE));
try (LocalQueryRunner localQueryRunner = new LocalQueryRunner(TEST_SESSION)) {
QueryContext queryContext = new QueryContext(
new QueryId("query"),
new DataSize(10, BYTE), // user memory limit
new DataSize(20, BYTE), // total memory limit
new DataSize(10, BYTE),
new DataSize(1, GIGABYTE),
generalPool,
new TestingGcMonitor(),
localQueryRunner.getExecutor(),
localQueryRunner.getScheduler(),
new DataSize(0, BYTE),
new SpillSpaceTracker(new DataSize(0, BYTE)),
listJsonCodec(TaskMemoryReservationSummary.class));

queryContext.getQueryMemoryContext().initializeLocalMemoryContexts("test");
LocalMemoryContext systemMemoryContext = queryContext.getQueryMemoryContext().localSystemMemoryContext();
LocalMemoryContext userMemoryContext = queryContext.getQueryMemoryContext().localUserMemoryContext();
try {
systemMemoryContext.setBytes(15, true);
userMemoryContext.setBytes(6);
}
catch (ExceededMemoryLimitException e) {
assertTrue(e.getMessage().contains("Query exceeded per-node broadcast memory limit of 10B"));
assertEquals(generalPool.getReservedBytes(), 0);
}
}
}

@Test
public void testMoveTaggedAllocations()
{
Expand Down