Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
LogByteSizeMergePolicyProvider.INDEX_LBS_MAX_MERGED_DOCS_SETTING,
LogByteSizeMergePolicyProvider.INDEX_LBS_NO_CFS_RATIO_SETTING,
IndexSettings.DEFAULT_SEARCH_PIPELINE,
IndexSettings.SEGMENT_COUNTER_INCREMENT_STEP_SETTING,

// Settings for Searchable Snapshots
IndexSettings.SEARCHABLE_SNAPSHOT_REPOSITORY,
Expand Down
19 changes: 19 additions & 0 deletions server/src/main/java/org/opensearch/index/IndexSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,14 @@
Property.IndexScope
);

public static final Setting<Long> SEGMENT_COUNTER_INCREMENT_STEP_SETTING = Setting.longSetting(
"index.segment_counter_increment_step",
100000,
10,
Property.Dynamic,
Property.IndexScope
);

private final Index index;
private final Version version;
private final Logger logger;
Expand Down Expand Up @@ -914,6 +922,7 @@
private volatile double docIdFuzzySetFalsePositiveProbability;

private final boolean isCompositeIndex;
private volatile long segmentCounterIncrementStep;

/**
* Returns the default search fields for this index.
Expand Down Expand Up @@ -1063,6 +1072,7 @@
setMergeOnFlushPolicy(scopedSettings.get(INDEX_MERGE_ON_FLUSH_POLICY));
checkPendingFlushEnabled = scopedSettings.get(INDEX_CHECK_PENDING_FLUSH_ENABLED);
defaultSearchPipeline = scopedSettings.get(DEFAULT_SEARCH_PIPELINE);
segmentCounterIncrementStep = scopedSettings.get(SEGMENT_COUNTER_INCREMENT_STEP_SETTING);
/* There was unintentional breaking change got introduced with [OpenSearch-6424](https://github.com/opensearch-project/OpenSearch/pull/6424) (version 2.7).
* For indices created prior version (prior to 2.7) which has IndexSort type, they used to type cast the SortField.Type
* to higher bytes size like integer to long. This behavior was changed from OpenSearch 2.7 version not to
Expand Down Expand Up @@ -1200,6 +1210,7 @@
IndexMetadata.INDEX_REMOTE_TRANSLOG_REPOSITORY_SETTING,
this::setRemoteStoreTranslogRepository
);
scopedSettings.addSettingsUpdateConsumer(SEGMENT_COUNTER_INCREMENT_STEP_SETTING, this::setSegmentCounterIncrementStep);
}

private void setSearchIdleAfter(TimeValue searchIdleAfter) {
Expand Down Expand Up @@ -2034,4 +2045,12 @@
public void setRemoteStoreTranslogRepository(String remoteStoreTranslogRepository) {
this.remoteStoreTranslogRepository = remoteStoreTranslogRepository;
}

public long getSegmentCounterIncrementStep() {
return segmentCounterIncrementStep;
}

public void setSegmentCounterIncrementStep(long segmentCounterIncrementStep) {
this.segmentCounterIncrementStep = segmentCounterIncrementStep;
}

Check warning on line 2055 in server/src/main/java/org/opensearch/index/IndexSettings.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/org/opensearch/index/IndexSettings.java#L2054-L2055

Added lines #L2054 - L2055 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ public class NRTReplicationEngine extends Engine {

private volatile long lastReceivedPrimaryGen = SequenceNumbers.NO_OPS_PERFORMED;

private static final int SI_COUNTER_INCREMENT = 10;

public NRTReplicationEngine(EngineConfig engineConfig) {
super(engineConfig);
store.incRef();
Expand Down Expand Up @@ -443,7 +441,8 @@ protected final void closeNoLock(String reason, CountDownLatch closedLatch) {
*/
if (engineConfig.getIndexSettings().isRemoteStoreEnabled() == false
&& engineConfig.getIndexSettings().isAssignedOnRemoteNode() == false) {
latestSegmentInfos.counter = latestSegmentInfos.counter + SI_COUNTER_INCREMENT;
latestSegmentInfos.counter = latestSegmentInfos.counter + engineConfig.getIndexSettings()
.getSegmentCounterIncrementStep();
latestSegmentInfos.changed();
}
try {
Expand Down
Loading