Skip to content

Commit 410733d

Browse files
committed
Enabled Async Shard Batch Fetch by default
Signed-off-by: Manik Garg <gargmanik1317@gmail.com>
1 parent 96481cc commit 410733d

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
77
### Added
88
- Add multi-threaded writer support in pull-based ingestion ([#17912](https://github.com/opensearch-project/OpenSearch/pull/17912))
99
- Implement parallel shard refresh behind cluster settings ([#17782](https://github.com/opensearch-project/OpenSearch/pull/17782))
10+
- Enabled Async Shard Batch Fetch by default ([#17987](https://github.com/opensearch-project/OpenSearch/pull/17987))
1011

1112
### Changed
1213

server/src/main/java/org/opensearch/cluster/routing/allocation/ExistingShardsAllocator.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,19 @@ public interface ExistingShardsAllocator {
6464

6565
/**
6666
* Boolean setting to enable/disable batch allocation of unassigned shards already existing on disk.
67-
* This will allow sending all Unassigned Shards to the ExistingShard Allocator to make decision to allocate
67+
* This will allow sending all Unassigned Shards to the ExistingShard Allocator to make decision to allocate
6868
* in one or more go.
69-
*
70-
* Enable this setting if your ExistingShardAllocator is implementing the
69+
* <p>
70+
* This setting is enabled by default. In your ExistingShardAllocator implement the
7171
* {@link ExistingShardsAllocator#allocateAllUnassignedShards(RoutingAllocation, boolean)} method.
7272
* The default implementation of this method is not optimized and assigns shards one by one.
73-
*
74-
* If no plugin overrides {@link ExistingShardsAllocator} then default implementation will be use for it , i.e,
73+
* <p>
74+
* If no plugin overrides {@link ExistingShardsAllocator} then default implementation will be used for it , i.e,
7575
* {@link ShardsBatchGatewayAllocator}.
76-
*
77-
* This setting is experimental at this point.
7876
*/
7977
Setting<Boolean> EXISTING_SHARDS_ALLOCATOR_BATCH_MODE = Setting.boolSetting(
8078
"cluster.allocator.existing_shards_allocator.batch_enabled",
81-
false,
79+
true,
8280
Setting.Property.NodeScope
8381
);
8482

server/src/main/java/org/opensearch/gateway/ShardsBatchGatewayAllocator.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public class ShardsBatchGatewayAllocator implements ExistingShardsAllocator {
8585
private TimeValue replicaShardsBatchGatewayAllocatorTimeout;
8686
private volatile Priority followUpRerouteTaskPriority;
8787
public static final TimeValue MIN_ALLOCATOR_TIMEOUT = TimeValue.timeValueSeconds(20);
88+
public static final TimeValue DEFAULT_ALLOCATOR_TIMEOUT = TimeValue.timeValueSeconds(20);
8889
private final ClusterManagerMetrics clusterManagerMetrics;
8990

9091
/**
@@ -105,7 +106,7 @@ public class ShardsBatchGatewayAllocator implements ExistingShardsAllocator {
105106
*/
106107
public static final Setting<TimeValue> PRIMARY_BATCH_ALLOCATOR_TIMEOUT_SETTING = Setting.timeSetting(
107108
PRIMARY_BATCH_ALLOCATOR_TIMEOUT_SETTING_KEY,
108-
TimeValue.MINUS_ONE,
109+
DEFAULT_ALLOCATOR_TIMEOUT,
109110
TimeValue.MINUS_ONE,
110111
new Setting.Validator<>() {
111112
@Override
@@ -129,7 +130,7 @@ public void validate(TimeValue timeValue) {
129130
*/
130131
public static final Setting<TimeValue> REPLICA_BATCH_ALLOCATOR_TIMEOUT_SETTING = Setting.timeSetting(
131132
REPLICA_BATCH_ALLOCATOR_TIMEOUT_SETTING_KEY,
132-
TimeValue.MINUS_ONE,
133+
DEFAULT_ALLOCATOR_TIMEOUT,
133134
TimeValue.MINUS_ONE,
134135
new Setting.Validator<>() {
135136
@Override

server/src/test/java/org/opensearch/cluster/routing/allocation/AllocationServiceTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@
5959
import org.opensearch.common.settings.ClusterSettings;
6060
import org.opensearch.common.settings.Settings;
6161
import org.opensearch.gateway.GatewayAllocator;
62+
import org.opensearch.gateway.ShardsBatchGatewayAllocator;
6263
import org.opensearch.snapshots.EmptySnapshotsInfoService;
6364
import org.opensearch.telemetry.metrics.Histogram;
6465
import org.opensearch.telemetry.metrics.MetricsRegistry;
6566
import org.opensearch.telemetry.metrics.noop.NoopMetricsRegistry;
6667
import org.opensearch.test.OpenSearchTestCase;
6768
import org.opensearch.test.gateway.TestGatewayAllocator;
69+
import org.opensearch.test.gateway.TestShardBatchGatewayAllocator;
6870

6971
import java.util.Arrays;
7072
import java.util.Collections;
@@ -192,8 +194,10 @@ public ShardAllocationDecision decideShardAllocation(ShardRouting shard, Routing
192194
final String unrealisticAllocatorName = "unrealistic";
193195
final Map<String, ExistingShardsAllocator> allocatorMap = new HashMap<>();
194196
final TestGatewayAllocator testGatewayAllocator = new TestGatewayAllocator();
197+
final TestShardBatchGatewayAllocator testShardBatchGatewayAllocator = new TestShardBatchGatewayAllocator();
195198
allocatorMap.put(GatewayAllocator.ALLOCATOR_NAME, testGatewayAllocator);
196199
allocatorMap.put(unrealisticAllocatorName, new UnrealisticAllocator());
200+
allocatorMap.put(ShardsBatchGatewayAllocator.ALLOCATOR_NAME, testShardBatchGatewayAllocator);
197201
allocationService.setExistingShardsAllocators(allocatorMap);
198202

199203
final DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder();

0 commit comments

Comments
 (0)