Skip to content

Commit b22bf83

Browse files
Deprecate indices.merge.scheduler.use_thread_pool setting (#129464)
This deprecates the `indices.merge.scheduler.use_thread_pool` setting that was introduced in #120869 because this setting should not normally be used, unless instructed so by engineering to get around temporary issues with the new threadpool-based merge scheduler.
1 parent 5b1faf7 commit b22bf83

File tree

9 files changed

+105
-2
lines changed

9 files changed

+105
-2
lines changed

docs/changelog/129464.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pr: 129464
2+
summary: Deprecate `indices.merge.scheduler.use_thread_pool` setting
3+
area: Engine
4+
type: deprecation
5+
issues: []
6+
deprecation:
7+
title: Deprecate `indices.merge.scheduler.use_thread_pool` setting
8+
area: Ingest
9+
details: This deprecates the `indices.merge.scheduler.use_thread_pool` node setting that was introduced in #120869. This setting should not normally be used, unless instructed so by engineering to get around temporary issues with the new threadpool-based merge scheduler.
10+
impact: There should be no impact to users since the setting was not released before its deprecation here (and is not documented).

server/src/main/java/org/elasticsearch/index/engine/ElasticsearchConcurrentMergeScheduler.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
/**
3232
* An extension to the {@link ConcurrentMergeScheduler} that provides tracking on merge times, total
3333
* and current merges.
34+
* @deprecated Replaced by {@link org.elasticsearch.index.engine.ThreadPoolMergeScheduler}. This merge scheduler
35+
* implementation should only be used to get around unexpected issues with the {@link ThreadPoolMergeScheduler},
36+
* which is the default one.
3437
*/
38+
@Deprecated
3539
public class ElasticsearchConcurrentMergeScheduler extends ConcurrentMergeScheduler implements ElasticsearchMergeScheduler {
3640

3741
protected final Logger logger;

server/src/main/java/org/elasticsearch/index/engine/ThreadPoolMergeScheduler.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,22 @@
4343
import java.util.concurrent.atomic.AtomicLong;
4444

4545
public class ThreadPoolMergeScheduler extends MergeScheduler implements ElasticsearchMergeScheduler {
46+
/**
47+
* This setting switches between the original {@link ElasticsearchConcurrentMergeScheduler}
48+
* and the new {@link ThreadPoolMergeScheduler} merge scheduler implementations (the latter is switched ON by default).
49+
* This setting is purposefully undocumented, because we expect that only the new {@link ThreadPoolMergeScheduler} implementation
50+
* (which is enabled by default) be used from now on. Our users should not touch this setting in their deployments,
51+
* unless consulting with engineering, because the original implementation should only be used (by setting this to {@code false})
52+
* to get around unexpected issues with the new one.
53+
* The setting is also <b>deprecated</b> in the hope that any unexpected issues with the new merge scheduler implementation are
54+
* promptly resolved, such that, in the near future, there's never a need to switch to the original implementation,
55+
* which will then be removed together with this setting.
56+
*/
4657
public static final Setting<Boolean> USE_THREAD_POOL_MERGE_SCHEDULER_SETTING = Setting.boolSetting(
4758
"indices.merge.scheduler.use_thread_pool",
4859
true,
49-
Setting.Property.NodeScope
60+
Setting.Property.NodeScope,
61+
Setting.Property.Deprecated
5062
);
5163
private final ShardId shardId;
5264
private final MergeSchedulerConfig config;

server/src/test/java/org/elasticsearch/action/support/replication/TransportReplicationAllPermitsAcquisitionTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ void runWithPrimaryShardReference(final TransportReplicationAction.PrimaryShardR
391391
}
392392
}
393393
}
394+
assertWarnings(
395+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch and will be removed in a future release. "
396+
+ "See the breaking changes documentation for the next major version."
397+
);
394398
}
395399

396400
private void assertSuccessfulOperation(final TestAction action, final Response response) {

server/src/test/java/org/elasticsearch/index/engine/ThreadPoolMergeExecutorServiceDiskSpaceTests.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public class ThreadPoolMergeExecutorServiceDiskSpaceTests extends ESTestCase {
6767
private static Settings settings;
6868
private static TestCapturingThreadPool testThreadPool;
6969
private static NodeEnvironment nodeEnvironment;
70+
private static boolean setThreadPoolMergeSchedulerSetting;
7071

7172
@BeforeClass
7273
public static void installMockUsableSpaceFS() throws Exception {
@@ -86,7 +87,8 @@ public static void installMockUsableSpaceFS() throws Exception {
8687
// the default of "5s" slows down testing
8788
.put(ThreadPoolMergeExecutorService.INDICES_MERGE_DISK_CHECK_INTERVAL_SETTING.getKey(), "50ms")
8889
.put(EsExecutors.NODE_PROCESSORS_SETTING.getKey(), mergeExecutorThreadCount);
89-
if (randomBoolean()) {
90+
setThreadPoolMergeSchedulerSetting = randomBoolean();
91+
if (setThreadPoolMergeSchedulerSetting) {
9092
settingsBuilder.put(ThreadPoolMergeScheduler.USE_THREAD_POOL_MERGE_SCHEDULER_SETTING.getKey(), true);
9193
}
9294
settings = settingsBuilder.build();
@@ -520,6 +522,12 @@ public void testAvailableDiskSpaceMonitorSettingsUpdate() throws Exception {
520522
}
521523
}, 5, TimeUnit.SECONDS);
522524
}
525+
if (setThreadPoolMergeSchedulerSetting) {
526+
assertWarnings(
527+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch "
528+
+ "and will be removed in a future release. See the breaking changes documentation for the next major version."
529+
);
530+
}
523531
}
524532

525533
public void testAbortingOrRunningMergeTaskHoldsUpBudget() throws Exception {
@@ -593,6 +601,12 @@ public void testAbortingOrRunningMergeTaskHoldsUpBudget() throws Exception {
593601
assertThat(threadPoolMergeExecutorService.allDone(), is(true));
594602
});
595603
}
604+
if (setThreadPoolMergeSchedulerSetting) {
605+
assertWarnings(
606+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch "
607+
+ "and will be removed in a future release. See the breaking changes documentation for the next major version."
608+
);
609+
}
596610
}
597611

598612
public void testBackloggedMergeTasksDoNotHoldUpBudget() throws Exception {
@@ -731,6 +745,12 @@ && randomBoolean()) {
731745
assertThat(threadPoolMergeExecutorService.allDone(), is(true));
732746
});
733747
}
748+
if (setThreadPoolMergeSchedulerSetting) {
749+
assertWarnings(
750+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch "
751+
+ "and will be removed in a future release. See the breaking changes documentation for the next major version."
752+
);
753+
}
734754
}
735755

736756
public void testUnavailableBudgetBlocksNewMergeTasksFromStartingExecution() throws Exception {
@@ -868,6 +888,12 @@ public void testUnavailableBudgetBlocksNewMergeTasksFromStartingExecution() thro
868888
assertThat(threadPoolMergeExecutorService.allDone(), is(true));
869889
});
870890
}
891+
if (setThreadPoolMergeSchedulerSetting) {
892+
assertWarnings(
893+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch "
894+
+ "and will be removed in a future release. See the breaking changes documentation for the next major version."
895+
);
896+
}
871897
}
872898

873899
public void testMergeTasksAreUnblockedWhenMoreDiskSpaceBecomesAvailable() throws Exception {
@@ -1019,5 +1045,11 @@ public void testMergeTasksAreUnblockedWhenMoreDiskSpaceBecomesAvailable() throws
10191045
);
10201046
});
10211047
}
1048+
if (setThreadPoolMergeSchedulerSetting) {
1049+
assertWarnings(
1050+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch "
1051+
+ "and will be removed in a future release. See the breaking changes documentation for the next major version."
1052+
);
1053+
}
10221054
}
10231055
}

server/src/test/java/org/elasticsearch/index/engine/ThreadPoolMergeExecutorServiceTests.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ public void testEnqueuedAndBackloggedMergesAreStillExecutedWhenThreadPoolIsShutd
211211
});
212212
assertThat(countingListener.aborted.get() + countingListener.completed.get(), equalTo(doneMergesCount.get()));
213213
assertThat(countingListener.aborted.get(), equalTo(abortedMergesCount.get()));
214+
assertWarnings(
215+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch and will be removed in a future release. "
216+
+ "See the breaking changes documentation for the next major version."
217+
);
214218
}
215219

216220
public void testTargetIORateChangesWhenSubmittingMergeTasks() throws Exception {
@@ -298,6 +302,10 @@ public void testTargetIORateChangesWhenSubmittingMergeTasks() throws Exception {
298302
}
299303
assertBusy(() -> assertTrue(threadPoolMergeExecutorService.allDone()));
300304
}
305+
assertWarnings(
306+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch and will be removed in a future release. "
307+
+ "See the breaking changes documentation for the next major version."
308+
);
301309
}
302310

303311
public void testIORateIsAdjustedForAllRunningMergeTasks() throws Exception {
@@ -386,6 +394,10 @@ public void testIORateIsAdjustedForAllRunningMergeTasks() throws Exception {
386394
}
387395
assertBusy(() -> assertTrue(threadPoolMergeExecutorService.allDone()));
388396
}
397+
assertWarnings(
398+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch and will be removed in a future release. "
399+
+ "See the breaking changes documentation for the next major version."
400+
);
389401
}
390402

391403
public void testIORateAdjustedForSubmittedTasksWhenExecutionRateIsSpeedy() throws IOException {
@@ -567,6 +579,10 @@ public void testMergeTasksRunConcurrently() throws Exception {
567579
}
568580
assertBusy(() -> assertTrue(threadPoolMergeExecutorService.allDone()));
569581
}
582+
assertWarnings(
583+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch and will be removed in a future release. "
584+
+ "See the breaking changes documentation for the next major version."
585+
);
570586
}
571587

572588
public void testThreadPoolStatsWithBackloggedMergeTasks() throws Exception {
@@ -626,6 +642,10 @@ public void testThreadPoolStatsWithBackloggedMergeTasks() throws Exception {
626642
assertTrue(threadPoolMergeExecutorService.allDone());
627643
});
628644
}
645+
assertWarnings(
646+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch and will be removed in a future release. "
647+
+ "See the breaking changes documentation for the next major version."
648+
);
629649
}
630650

631651
public void testBackloggedMergeTasksExecuteExactlyOnce() throws Exception {
@@ -697,6 +717,10 @@ public void testBackloggedMergeTasksExecuteExactlyOnce() throws Exception {
697717
assertTrue(threadPoolMergeExecutorService.allDone());
698718
});
699719
}
720+
assertWarnings(
721+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch and will be removed in a future release. "
722+
+ "See the breaking changes documentation for the next major version."
723+
);
700724
}
701725

702726
public void testMergeTasksExecuteInSizeOrder() throws IOException {

server/src/test/java/org/elasticsearch/index/replication/IndexLevelReplicationTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ public void testLateDeliveryAfterGCTriggeredOnReplica() throws Exception {
666666
indexOnReplica(indexRequest, shards, replica); // index arrives on replica lately.
667667
shards.assertAllEqual(0);
668668
}
669+
assertWarnings(
670+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch and will be removed in a future release. "
671+
+ "See the breaking changes documentation for the next major version."
672+
);
669673
}
670674

671675
private void updateGCDeleteCycle(IndexShard shard, TimeValue interval) {

server/src/test/java/org/elasticsearch/index/shard/RefreshListenersTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ public void onFailedEngine(String reason, @Nullable Exception e) {
186186

187187
@After
188188
public void tearDownListeners() throws Exception {
189+
assertWarnings(
190+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch and will be removed in a future release. "
191+
+ "See the breaking changes documentation for the next major version."
192+
);
189193
IOUtils.close(engine, store, nodeEnvironment, () -> terminate(threadPool));
190194
}
191195

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/repository/CcrRestoreSourceServiceTests.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.elasticsearch.index.store.Store;
2525
import org.elasticsearch.index.store.StoreFileMetadata;
2626
import org.elasticsearch.xpack.ccr.CcrSettings;
27+
import org.junit.After;
2728
import org.junit.Before;
2829

2930
import java.io.IOException;
@@ -49,6 +50,14 @@ public void setUp() throws Exception {
4950
restoreSourceService = new CcrRestoreSourceService(taskQueue.getThreadPool(), new CcrSettings(Settings.EMPTY, clusterSettings));
5051
}
5152

53+
@After
54+
public void assertWarnings() {
55+
assertWarnings(
56+
"[indices.merge.scheduler.use_thread_pool] setting was deprecated in Elasticsearch and will be removed in a future release. "
57+
+ "See the breaking changes documentation for the next major version."
58+
);
59+
}
60+
5261
public void testOpenSession() throws IOException {
5362
IndexShard indexShard1 = newStartedShard(true);
5463
IndexShard indexShard2 = newStartedShard(true);

0 commit comments

Comments
 (0)