Skip to content

Commit f4a712b

Browse files
committed
Add comments
Signed-off-by: guojialiang <[email protected]>
1 parent f3fec76 commit f4a712b

File tree

1 file changed

+3
-0
lines changed
  • server/src/main/java/org/opensearch/indices/replication/common

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public CopyState(IndexShard shard) throws IOException {
4949
SegmentInfos segmentInfosSnapshot = segmentInfos.clone();
5050
Map<String, String> userData = segmentInfosSnapshot.getUserData();
5151
long maxSeqNo = Long.parseLong(userData.getOrDefault(SequenceNumbers.MAX_SEQ_NO, "-1"));
52+
// In the scenario of vanilla segment replication. We need to ensure that after the primary promotion,
53+
// the SegmentInfos#version of the primary shard is always greater than or equal to that of the replicas.
54+
// At the same time, it is also necessary to ensure that there is no risk of data loss.
5255
userData.put(SequenceNumbers.MAX_SEQ_NO, Long.toString(Math.min(maxSeqNo, lastRefreshedCheckpoint)));
5356
segmentInfosSnapshot.setUserData(userData, false);
5457

0 commit comments

Comments
 (0)