Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c3d39c5

Browse files
committedMar 11, 2025·
add segment counter increment step setting
Signed-off-by: guojialiang.2012 <guojialiang.2012@bytedance.com>
1 parent e397903 commit c3d39c5

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed
 

‎server/src/main/java/org/opensearch/common/settings/IndexScopedSettings.java

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
222222
LogByteSizeMergePolicyProvider.INDEX_LBS_MAX_MERGED_DOCS_SETTING,
223223
LogByteSizeMergePolicyProvider.INDEX_LBS_NO_CFS_RATIO_SETTING,
224224
IndexSettings.DEFAULT_SEARCH_PIPELINE,
225+
IndexSettings.SEGMENT_COUNTER_INCREMENT_STEP_SETTING,
225226

226227
// Settings for Searchable Snapshots
227228
IndexSettings.SEARCHABLE_SNAPSHOT_REPOSITORY,

‎server/src/main/java/org/opensearch/index/IndexSettings.java

+19
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,14 @@ public static IndexMergePolicy fromString(String text) {
782782
Property.IndexScope
783783
);
784784

785+
public static final Setting<Long> SEGMENT_COUNTER_INCREMENT_STEP_SETTING = Setting.longSetting(
786+
"index.segment_counter_increment_step",
787+
100000,
788+
10,
789+
Property.Dynamic,
790+
Property.IndexScope
791+
);
792+
785793
private final Index index;
786794
private final Version version;
787795
private final Logger logger;
@@ -913,6 +921,7 @@ private void setRetentionLeaseMillis(final TimeValue retentionLease) {
913921
private volatile double docIdFuzzySetFalsePositiveProbability;
914922

915923
private final boolean isCompositeIndex;
924+
private volatile long segmentCounterIncrementStep;
916925

917926
/**
918927
* Returns the default search fields for this index.
@@ -1063,6 +1072,7 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
10631072
setMergeOnFlushPolicy(scopedSettings.get(INDEX_MERGE_ON_FLUSH_POLICY));
10641073
checkPendingFlushEnabled = scopedSettings.get(INDEX_CHECK_PENDING_FLUSH_ENABLED);
10651074
defaultSearchPipeline = scopedSettings.get(DEFAULT_SEARCH_PIPELINE);
1075+
segmentCounterIncrementStep = scopedSettings.get(SEGMENT_COUNTER_INCREMENT_STEP_SETTING);
10661076
/* There was unintentional breaking change got introduced with [OpenSearch-6424](https://github.com/opensearch-project/OpenSearch/pull/6424) (version 2.7).
10671077
* For indices created prior version (prior to 2.7) which has IndexSort type, they used to type cast the SortField.Type
10681078
* to higher bytes size like integer to long. This behavior was changed from OpenSearch 2.7 version not to
@@ -1200,6 +1210,7 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
12001210
IndexMetadata.INDEX_REMOTE_TRANSLOG_REPOSITORY_SETTING,
12011211
this::setRemoteStoreTranslogRepository
12021212
);
1213+
scopedSettings.addSettingsUpdateConsumer(SEGMENT_COUNTER_INCREMENT_STEP_SETTING, this::setSegmentCounterIncrementStep);
12031214
}
12041215

12051216
private void setSearchIdleAfter(TimeValue searchIdleAfter) {
@@ -2034,4 +2045,12 @@ public void setRemoteStoreRepository(String remoteStoreRepository) {
20342045
public void setRemoteStoreTranslogRepository(String remoteStoreTranslogRepository) {
20352046
this.remoteStoreTranslogRepository = remoteStoreTranslogRepository;
20362047
}
2048+
2049+
public long getSegmentCounterIncrementStep() {
2050+
return segmentCounterIncrementStep;
2051+
}
2052+
2053+
public void setSegmentCounterIncrementStep(long segmentCounterIncrementStep) {
2054+
this.segmentCounterIncrementStep = segmentCounterIncrementStep;
2055+
}
20372056
}

‎server/src/main/java/org/opensearch/index/engine/NRTReplicationEngine.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ public class NRTReplicationEngine extends Engine {
6767

6868
private volatile long lastReceivedPrimaryGen = SequenceNumbers.NO_OPS_PERFORMED;
6969

70-
private static final int SI_COUNTER_INCREMENT = 10;
71-
7270
public NRTReplicationEngine(EngineConfig engineConfig) {
7371
super(engineConfig);
7472
store.incRef();
@@ -438,7 +436,8 @@ protected final void closeNoLock(String reason, CountDownLatch closedLatch) {
438436
*/
439437
if (engineConfig.getIndexSettings().isRemoteStoreEnabled() == false
440438
&& engineConfig.getIndexSettings().isAssignedOnRemoteNode() == false) {
441-
latestSegmentInfos.counter = latestSegmentInfos.counter + SI_COUNTER_INCREMENT;
439+
latestSegmentInfos.counter = latestSegmentInfos.counter + engineConfig.getIndexSettings()
440+
.getSegmentCounterIncrementStep();
442441
latestSegmentInfos.changed();
443442
}
444443
try {

0 commit comments

Comments
 (0)
Please sign in to comment.