Skip to content

Commit 740deb3

Browse files
committed
put Math.min(maxSeqNo, lastRefreshedCheckpoint) in max_seq_no
Signed-off-by: guojialiang <[email protected]>
1 parent 8ba8c98 commit 740deb3

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

server/src/main/java/org/opensearch/index/engine/InternalEngine.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,7 @@ public void onAfterTranslogSync() {
269269

270270
@Override
271271
public void onAfterTranslogRecovery() {
272-
// In the scenario of vanilla segment replication, the force parameter is used to ensure that the
273-
// SegmentInfos#version of the primary shard is greater than or equal to that of the replicas.
274-
boolean isForceFlush = engineConfig.getIndexSettings().isSegRepLocalEnabled();
275-
flush(isForceFlush, true);
272+
flush(false, true);
276273
translogManager.trimUnreferencedTranslogFiles();
277274
}
278275

server/src/main/java/org/opensearch/indices/replication/common/CopyState.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import java.io.UncheckedIOException;
2424
import java.util.Map;
2525

26-
import static org.opensearch.index.seqno.SequenceNumbers.LOCAL_CHECKPOINT_KEY;
27-
2826
/**
2927
* An Opensearch-specific version of Lucene's CopyState class that
3028
* holds incRef'd file level details for one point-in-time segment infos.
@@ -50,8 +48,8 @@ public CopyState(IndexShard shard) throws IOException {
5048

5149
SegmentInfos segmentInfosSnapshot = segmentInfos.clone();
5250
Map<String, String> userData = segmentInfosSnapshot.getUserData();
53-
userData.put(LOCAL_CHECKPOINT_KEY, String.valueOf(lastRefreshedCheckpoint));
54-
userData.put(SequenceNumbers.MAX_SEQ_NO, Long.toString(lastRefreshedCheckpoint));
51+
long maxSeqNo = Long.parseLong(userData.get(SequenceNumbers.MAX_SEQ_NO));
52+
userData.put(SequenceNumbers.MAX_SEQ_NO, Long.toString(Math.min(maxSeqNo, lastRefreshedCheckpoint)));
5553
segmentInfosSnapshot.setUserData(userData, false);
5654

5755
ByteBuffersDataOutput buffer = new ByteBuffersDataOutput();

0 commit comments

Comments
 (0)