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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add metrics for the merged segment warmer feature ([#18929](https://github.com/opensearch-project/OpenSearch/pull/18929))
- Add pointer based lag metric in pull-based ingestion ([#19635](https://github.com/opensearch-project/OpenSearch/pull/19635))
- Introduced internal API for retrieving metadata about requested indices from transport actions ([#18523](https://github.com/opensearch-project/OpenSearch/pull/18523))
- Add cluster defaults for merge autoThrottle, maxMergeThreads, and maxMergeCount; Add segment size filter to the merged segment warmer ([#19629](https://github.com/opensearch-project/OpenSearch/pull/19629))

### Changed
- Faster `terms` query creation for `keyword` field with index and docValues enabled ([#19350](https://github.com/opensearch-project/OpenSearch/pull/19350))
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(RecoverySettings.INDICES_MERGED_SEGMENT_REPLICATION_WARMER_ENABLED_SETTING.getKey(), true)
.put(RecoverySettings.INDICES_REPLICATION_MERGES_WARMER_MIN_SEGMENT_SIZE_THRESHOLD_SETTING.getKey(), "1b")
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ protected Settings nodeSettings(int nodeOrdinal) {
.put(super.nodeSettings(nodeOrdinal))
.put(remoteStoreClusterSettings("test-remote-store-repo", absolutePath))
.put(RecoverySettings.INDICES_MERGED_SEGMENT_REPLICATION_WARMER_ENABLED_SETTING.getKey(), true)
.put(RecoverySettings.INDICES_REPLICATION_MERGES_WARMER_MIN_SEGMENT_SIZE_THRESHOLD_SETTING.getKey(), "1b")
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ protected Settings nodeSettings(int nodeOrdinal) {
return Settings.builder()
.put(super.nodeSettings(nodeOrdinal))
.put(RecoverySettings.INDICES_MERGED_SEGMENT_REPLICATION_WARMER_ENABLED_SETTING.getKey(), true)
.put(RecoverySettings.INDICES_REPLICATION_MERGES_WARMER_MIN_SEGMENT_SIZE_THRESHOLD_SETTING.getKey(), "1b")
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
import org.opensearch.index.remote.RemoteStorePressureSettings;
import org.opensearch.index.remote.RemoteStoreStatsTrackerFactory;
import org.opensearch.index.store.remote.filecache.FileCacheSettings;
import org.opensearch.indices.ClusterMergeSchedulerConfig;
import org.opensearch.indices.IndexingMemoryController;
import org.opensearch.indices.IndicesQueryCache;
import org.opensearch.indices.IndicesRequestCache;
Expand Down Expand Up @@ -307,6 +308,9 @@ public void apply(Settings value, Settings current, Settings previous) {
IndicesQueryCache.INDICES_QUERIES_CACHE_SKIP_CACHE_FACTOR,
IndicesQueryCache.INDICES_QUERY_CACHE_MIN_FREQUENCY,
IndicesQueryCache.INDICES_QUERY_CACHE_COSTLY_MIN_FREQUENCY,
ClusterMergeSchedulerConfig.CLUSTER_MAX_THREAD_COUNT_SETTING,
ClusterMergeSchedulerConfig.CLUSTER_MAX_MERGE_COUNT_SETTING,
ClusterMergeSchedulerConfig.CLUSTER_AUTO_THROTTLE_SETTING,
IndicesService.CLUSTER_DEFAULT_INDEX_MAX_MERGE_AT_ONCE_SETTING,
IndicesService.CLUSTER_DEFAULT_INDEX_REFRESH_INTERVAL_SETTING,
IndicesService.CLUSTER_MINIMUM_INDEX_REFRESH_INTERVAL_SETTING,
Expand All @@ -326,6 +330,7 @@ public void apply(Settings value, Settings current, Settings previous) {
ShardLimitValidator.SETTING_CLUSTER_IGNORE_DOT_INDEXES,
RecoverySettings.INDICES_RECOVERY_MAX_BYTES_PER_SEC_SETTING,
RecoverySettings.INDICES_REPLICATION_MAX_BYTES_PER_SEC_SETTING,
RecoverySettings.INDICES_REPLICATION_MERGES_WARMER_MIN_SEGMENT_SIZE_THRESHOLD_SETTING,
RecoverySettings.INDICES_MERGED_SEGMENT_REPLICATION_WARMER_ENABLED_SETTING,
RecoverySettings.INDICES_MERGED_SEGMENT_REPLICATION_MAX_BYTES_PER_SEC_SETTING,
RecoverySettings.INDICES_MERGED_SEGMENT_REPLICATION_TIMEOUT_SETTING,
Expand Down
67 changes: 39 additions & 28 deletions server/src/main/java/org/opensearch/index/IndexModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
import org.opensearch.index.store.remote.directory.RemoteSnapshotDirectoryFactory;
import org.opensearch.index.store.remote.filecache.FileCache;
import org.opensearch.index.translog.TranslogFactory;
import org.opensearch.indices.ClusterMergeSchedulerConfig;
import org.opensearch.indices.IndicesQueryCache;
import org.opensearch.indices.RemoteStoreSettings;
import org.opensearch.indices.fielddata.cache.IndicesFieldDataCache;
Expand Down Expand Up @@ -670,33 +671,8 @@ public IndexService newIndexService(
RemoteStoreSettings remoteStoreSettings,
Supplier<Integer> clusterDefaultMaxMergeAtOnceSupplier
) throws IOException {
return newIndexService(
indexCreationContext,
environment,
xContentRegistry,
shardStoreDeleter,
circuitBreakerService,
bigArrays,
threadPool,
scriptService,
clusterService,
client,
indicesQueryCache,
mapperRegistry,
indicesFieldDataCache,
namedWriteableRegistry,
idFieldDataEnabled,
valuesSourceRegistry,
remoteDirectoryFactory,
translogFactorySupplier,
clusterDefaultRefreshIntervalSupplier,
fixedRefreshIntervalSchedulingEnabled,
shardLevelRefreshEnabled,
recoverySettings,
remoteStoreSettings,
(s) -> {},
shardId -> ReplicationStats.empty(),
clusterDefaultMaxMergeAtOnceSupplier
throw new UnsupportedOperationException(
"This API is removed in OpenSearch version 3.4.0. " + "Use the new overloaded newIndexService() method instead."
);
}

Expand Down Expand Up @@ -727,6 +703,40 @@ public IndexService newIndexService(
Consumer<IndexShard> replicator,
Function<ShardId, ReplicationStats> segmentReplicationStatsProvider,
Supplier<Integer> clusterDefaultMaxMergeAtOnceSupplier
) throws IOException {
throw new UnsupportedOperationException(
"This API is removed in OpenSearch version 3.4.0. " + "Use the new overloaded newIndexService() method instead."
);
}

public IndexService newIndexService(
IndexService.IndexCreationContext indexCreationContext,
NodeEnvironment environment,
NamedXContentRegistry xContentRegistry,
IndexService.ShardStoreDeleter shardStoreDeleter,
CircuitBreakerService circuitBreakerService,
BigArrays bigArrays,
ThreadPool threadPool,
ScriptService scriptService,
ClusterService clusterService,
Client client,
IndicesQueryCache indicesQueryCache,
MapperRegistry mapperRegistry,
IndicesFieldDataCache indicesFieldDataCache,
NamedWriteableRegistry namedWriteableRegistry,
BooleanSupplier idFieldDataEnabled,
ValuesSourceRegistry valuesSourceRegistry,
IndexStorePlugin.DirectoryFactory remoteDirectoryFactory,
BiFunction<IndexSettings, ShardRouting, TranslogFactory> translogFactorySupplier,
Supplier<TimeValue> clusterDefaultRefreshIntervalSupplier,
Supplier<Boolean> fixedRefreshIntervalSchedulingEnabled,
Supplier<Boolean> shardLevelRefreshEnabled,
RecoverySettings recoverySettings,
RemoteStoreSettings remoteStoreSettings,
Consumer<IndexShard> replicator,
Function<ShardId, ReplicationStats> segmentReplicationStatsProvider,
Supplier<Integer> clusterDefaultMaxMergeAtOnceSupplier,
ClusterMergeSchedulerConfig clusterMergeSchedulerConfig
) throws IOException {
final IndexEventListener eventListener = freeze();
Function<IndexService, CheckedFunction<DirectoryReader, DirectoryReader, IOException>> readerWrapperFactory = indexReaderWrapper
Expand Down Expand Up @@ -798,7 +808,8 @@ public IndexService newIndexService(
compositeIndexSettings,
replicator,
segmentReplicationStatsProvider,
clusterDefaultMaxMergeAtOnceSupplier
clusterDefaultMaxMergeAtOnceSupplier,
clusterMergeSchedulerConfig
);
success = true;
return indexService;
Expand Down
40 changes: 36 additions & 4 deletions server/src/main/java/org/opensearch/index/IndexService.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import org.opensearch.index.store.remote.filecache.FileCache;
import org.opensearch.index.translog.Translog;
import org.opensearch.index.translog.TranslogFactory;
import org.opensearch.indices.ClusterMergeSchedulerConfig;
import org.opensearch.indices.RemoteStoreSettings;
import org.opensearch.indices.cluster.IndicesClusterStateService;
import org.opensearch.indices.fielddata.cache.IndicesFieldDataCache;
Expand Down Expand Up @@ -252,7 +253,8 @@ public IndexService(
CompositeIndexSettings compositeIndexSettings,
Consumer<IndexShard> replicator,
Function<ShardId, ReplicationStats> segmentReplicationStatsProvider,
Supplier<Integer> clusterDefaultMaxMergeAtOnceSupplier
Supplier<Integer> clusterDefaultMaxMergeAtOnceSupplier,
ClusterMergeSchedulerConfig clusterMergeSchedulerConfig
) {
super(indexSettings);
this.storeFactory = storeFactory;
Expand Down Expand Up @@ -352,6 +354,11 @@ public IndexService(
this.replicator = replicator;
this.segmentReplicationStatsProvider = segmentReplicationStatsProvider;
indexSettings.setDefaultMaxMergesAtOnce(clusterDefaultMaxMergeAtOnceSupplier.get());
indexSettings.setDefaultMaxThreadAndMergeCount(
clusterMergeSchedulerConfig.getClusterMaxThreadCount(),
clusterMergeSchedulerConfig.getClusterMaxMergeCount()
);
indexSettings.setDefaultAutoThrottleEnabled(clusterMergeSchedulerConfig.getClusterMergeAutoThrottleEnabled());
updateFsyncTaskIfNecessary();
synchronized (refreshMutex) {
if (shardLevelRefreshEnabled == false) {
Expand Down Expand Up @@ -400,7 +407,8 @@ public IndexService(
boolean shardLevelRefreshEnabled,
RecoverySettings recoverySettings,
RemoteStoreSettings remoteStoreSettings,
Supplier<Integer> clusterDefaultMaxMergeAtOnce
Supplier<Integer> clusterDefaultMaxMergeAtOnce,
ClusterMergeSchedulerConfig clusterMergeSchedulerConfig
) {
this(
indexSettings,
Expand Down Expand Up @@ -445,7 +453,8 @@ public IndexService(
null,
s -> {},
(shardId) -> ReplicationStats.empty(),
clusterDefaultMaxMergeAtOnce
clusterDefaultMaxMergeAtOnce,
clusterMergeSchedulerConfig
);
}

Expand Down Expand Up @@ -1235,6 +1244,21 @@ public void onDefaultMaxMergeAtOnceChanged(int newDefaultMaxMergeAtOnce) {
indexSettings.setDefaultMaxMergesAtOnce(newDefaultMaxMergeAtOnce);
}

/**
* Called when the cluster level settings: {@code cluster.default.index.merge.scheduler.max_merge_count} OR
* {@code cluster.default.index.merge.scheduler.max_thread_count} change.
*/
public void onDefaultMaxMergeOrThreadCountUpdate(int maxThreadCount, int maxMergeCount) {
indexSettings.setDefaultMaxThreadAndMergeCount(maxThreadCount, maxMergeCount);
}

/**
* Called whenever the cluster level {@code cluster.default.index.merge.scheduler.auto_throttle} changes.
*/
public void onDefaultAutoThrottleEnabledUpdate(boolean enabled) {
indexSettings.setDefaultAutoThrottleEnabled(enabled);
}

/**
* Called whenever the cluster level {@code cluster.merge.scheduler.max_force_merge_mb_per_sec} changes.
* The change is only applied if the index doesn't have its own explicit force merge MB per sec setting.
Expand Down Expand Up @@ -1580,7 +1604,9 @@ final class AsyncPublishReferencedSegmentsTask extends BaseAsyncTask {

@Override
protected void runInternal() {
indexService.maybePublishReferencedSegments();
if (shouldRun()) {
indexService.maybePublishReferencedSegments();
}
}

@Override
Expand All @@ -1597,6 +1623,12 @@ public String toString() {
protected boolean mustReschedule() {
return indexSettings.isSegRepEnabledOrRemoteNode() && super.mustReschedule();
}

// visible for tests
protected boolean shouldRun() {
return (indexSettings.isSegRepLocalEnabled() || indexSettings.isRemoteStoreEnabled())
&& recoverySettings.isMergedSegmentReplicationWarmerEnabled();
}
}

private void maybePublishReferencedSegments() {
Expand Down
21 changes: 21 additions & 0 deletions server/src/main/java/org/opensearch/index/IndexSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,27 @@ void setDefaultMaxMergesAtOnce(int newDefaultMaxMergesAtOnce) {
}
}

/**
* Update the cached defaults for {@code MergeSchedulerConfig.MAX_THREAD_COUNT_SETTING} and
* {@code MergeSchedulerConfig.MAX_MERGE_COUNT_SETTING}
*/
void setDefaultMaxThreadAndMergeCount(int maxThreadCount, int maxMergeCount) {
// Upon updates to the cluster default settings, we always update the cached default values in
// the MergeSchedulerConfig, but we only update the actual values when an index level setting is not present
boolean overrideExistingConfigs = MergeSchedulerConfig.MAX_THREAD_COUNT_SETTING.exists(getSettings()) == false
&& MergeSchedulerConfig.MAX_MERGE_COUNT_SETTING.exists(getSettings()) == false;
mergeSchedulerConfig.setDefaultMaxThreadAndMergeCount(maxThreadCount, maxMergeCount, overrideExistingConfigs);
}

void setDefaultAutoThrottleEnabled(boolean enabled) {
// Upon updates to the cluster default settings, we always update the cached default values in
// the MergeSchedulerConfig, but we only update the actual values when an index level setting is not present
mergeSchedulerConfig.setDefaultAutoThrottleEnabled(
enabled,
MergeSchedulerConfig.AUTO_THROTTLE_SETTING.exists(getSettings()) == false
);
}

/**
* Updates the maxMergesAtOnce for actual TieredMergePolicy used by the engine.
* Sets it to default maxMergesAtOnce if index level settings is being removed
Expand Down
Loading
Loading