Fix ThreadPoolMergeExecutorServiceDiskSpaceTests testUnavailableBudgetBlocksNewMergeTasksFromStartingExecution (#130001)

The test might produce over-budget tasks that cannot run even if all the
other tasks that were blocked (and hold up budget) while running
complete. Rather than prevent submitting such over-budget tasks, this
fix simply sets the merge task's queue available budget to
`Long.MAX_VALUE`, in order to ensure that all merge tasks run before the
test ends.

Fixes https://github.com/elastic/elasticsearch/issues/129148
This commit is contained in:
Albert Zaharovits 2025-06-25 21:46:43 +03:00 committed by GitHub
parent d3e00bec73
commit 72b3343ed3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 8 deletions

View file

@ -476,9 +476,6 @@ tests:
- class: org.elasticsearch.index.engine.ThreadPoolMergeExecutorServiceDiskSpaceTests
method: testAvailableDiskSpaceMonitorWhenFileSystemStatErrors
issue: https://github.com/elastic/elasticsearch/issues/129149
- class: org.elasticsearch.index.engine.ThreadPoolMergeExecutorServiceDiskSpaceTests
method: testUnavailableBudgetBlocksNewMergeTasksFromStartingExecution
issue: https://github.com/elastic/elasticsearch/issues/129148
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeForkIT
method: test {lookup-join.EnrichLookupStatsBug ASYNC}
issue: https://github.com/elastic/elasticsearch/issues/129228

View file

@ -847,6 +847,7 @@ public class ThreadPoolMergeExecutorServiceDiskSpaceTests extends ESTestCase {
when(mergeTask2.schedule()).thenReturn(RUN);
boolean task1Runs = randomBoolean();
long currentAvailableBudget = expectedAvailableBudget.get();
// the over-budget here can be larger than the total initial available budget
long overBudget = randomLongBetween(currentAvailableBudget + 1L, currentAvailableBudget + 100L);
long underBudget = randomLongBetween(0L, currentAvailableBudget);
if (task1Runs) {
@ -882,11 +883,18 @@ public class ThreadPoolMergeExecutorServiceDiskSpaceTests extends ESTestCase {
// update the expected budget given that one task now finished
expectedAvailableBudget.set(expectedAvailableBudget.get() + completedMergeTask.estimatedRemainingMergeSize());
}
// let the test finish cleanly
assertBusy(() -> {
assertThat(threadPoolMergeExecutorService.getDiskSpaceAvailableForNewMergeTasks(), is(aHasMoreSpace ? 112_500L : 103_000L));
assertThat(threadPoolMergeExecutorService.allDone(), is(true));
});
assertBusy(
() -> assertThat(
threadPoolMergeExecutorService.getDiskSpaceAvailableForNewMergeTasks(),
is(aHasMoreSpace ? 112_500L : 103_000L)
)
);
// let the test finish cleanly (some tasks can be over budget even if all the other tasks finished running)
aFileStore.totalSpace = Long.MAX_VALUE;
bFileStore.totalSpace = Long.MAX_VALUE;
aFileStore.usableSpace = Long.MAX_VALUE;
bFileStore.usableSpace = Long.MAX_VALUE;
assertBusy(() -> assertThat(threadPoolMergeExecutorService.allDone(), is(true)));
}
if (setThreadPoolMergeSchedulerSetting) {
assertWarnings(