Skip to content

Throttle indexing when disk IO throttling is disabled #129245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
5 changes: 5 additions & 0 deletions docs/changelog/129245.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 129245
summary: Throttle indexing when disk IO throttling is disabled
area: Engine
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ private void checkMergeTaskThrottling() {
// both currently running and enqueued merge tasks are considered "active" for throttling purposes
int activeMerges = (int) (submittedMergesCount - doneMergesCount);
if (activeMerges > configuredMaxMergeCount
// only throttle indexing if disk IO is un-throttled, and we still can't keep up with the merge load
&& threadPoolMergeExecutorService.usingMaxTargetIORateBytesPerSec()
// only throttle indexing if disk IO is un-throttled (if enabled), and we still can't keep up with the merge load
&& (config.isAutoThrottle() == false || threadPoolMergeExecutorService.usingMaxTargetIORateBytesPerSec())
&& shouldThrottleIncomingMerges.get() == false) {
// maybe enable merge task throttling
synchronized (shouldThrottleIncomingMerges) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,15 @@ public void testSimpleMergeTaskReEnqueueingBySize() {
}
}

public void testIndexingThrottlingWhenSubmittingMerges() {
public void testIndexingThrottlingWhenSubmittingMergesWithDiskIOThrottlingEnabled() {
testIndexingThrottlingWhenSubmittingMerges(true);
}

public void testIndexingThrottlingWhenSubmittingMergesWithDiskIOThrottlingDisabled() {
testIndexingThrottlingWhenSubmittingMerges(false);
}

private void testIndexingThrottlingWhenSubmittingMerges(boolean withDiskIOThrottlingEnabled) {
final int maxThreadCount = randomIntBetween(1, 5);
// settings validation requires maxMergeCount >= maxThreadCount
final int maxMergeCount = maxThreadCount + randomIntBetween(0, 5);
Expand All @@ -209,6 +217,7 @@ public void testIndexingThrottlingWhenSubmittingMerges() {
Settings mergeSchedulerSettings = Settings.builder()
.put(MergeSchedulerConfig.MAX_THREAD_COUNT_SETTING.getKey(), maxThreadCount)
.put(MergeSchedulerConfig.MAX_MERGE_COUNT_SETTING.getKey(), maxMergeCount)
.put(MergeSchedulerConfig.AUTO_THROTTLE_SETTING.getKey(), withDiskIOThrottlingEnabled)
.build();
TestThreadPoolMergeScheduler threadPoolMergeScheduler = new TestThreadPoolMergeScheduler(
new ShardId("index", "_na_", 1),
Expand All @@ -224,20 +233,20 @@ public void testIndexingThrottlingWhenSubmittingMerges() {
while (submittedMerges < mergesToSubmit - 1) {
isUsingMaxTargetIORate.set(randomBoolean());
if (submittedMergeTasks.isEmpty() == false && randomBoolean()) {
// maybe schedule one submitted merge
// maybe schedule one of the submitted merges (but still it's not run)
MergeTask mergeTask = randomFrom(submittedMergeTasks);
submittedMergeTasks.remove(mergeTask);
mergeTask.schedule();
} else {
// submit one merge
// submit one new merge
MergeSource mergeSource = mock(MergeSource.class);
OneMerge oneMerge = mock(OneMerge.class);
when(oneMerge.getStoreMergeInfo()).thenReturn(getNewMergeInfo(randomLongBetween(1L, 10L)));
when(oneMerge.getMergeProgress()).thenReturn(new MergePolicy.OneMergeProgress());
when(mergeSource.getNextMerge()).thenReturn(oneMerge, (OneMerge) null);
threadPoolMergeScheduler.merge(mergeSource, randomFrom(MergeTrigger.values()));
submittedMerges++;
if (isUsingMaxTargetIORate.get() && submittedMerges > maxMergeCount) {
if ((isUsingMaxTargetIORate.get() || withDiskIOThrottlingEnabled == false) && submittedMerges > maxMergeCount) {
expectIndexThrottling = true;
} else if (submittedMerges <= maxMergeCount) {
expectIndexThrottling = false;
Expand All @@ -246,15 +255,20 @@ public void testIndexingThrottlingWhenSubmittingMerges() {
// assert IO throttle state
assertThat(threadPoolMergeScheduler.isIndexingThrottlingEnabled(), is(expectIndexThrottling));
}
// submit one last merge when IO throttling is at max value
isUsingMaxTargetIORate.set(true);
if (withDiskIOThrottlingEnabled) {
// submit one last merge when IO throttling is at max value
isUsingMaxTargetIORate.set(true);
} else {
// but if disk IO throttling is not enabled, indexing throttling should still be triggered
isUsingMaxTargetIORate.set(randomBoolean());
}
MergeSource mergeSource = mock(MergeSource.class);
OneMerge oneMerge = mock(OneMerge.class);
when(oneMerge.getStoreMergeInfo()).thenReturn(getNewMergeInfo(randomLongBetween(1L, 10L)));
when(oneMerge.getMergeProgress()).thenReturn(new MergePolicy.OneMergeProgress());
when(mergeSource.getNextMerge()).thenReturn(oneMerge, (OneMerge) null);
threadPoolMergeScheduler.merge(mergeSource, randomFrom(MergeTrigger.values()));
// assert index throttling because IO throttling is at max value
// assert indexing throttling state because IO throttling is at max value OR disk IO throttling is disabled
assertThat(threadPoolMergeScheduler.isIndexingThrottlingEnabled(), is(true));
}

Expand Down
Loading