Skip to content

Commit

Permalink
Add comment explaining the change
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <[email protected]>
  • Loading branch information
Sachin Kale committed Sep 14, 2023
1 parent 6b0ab08 commit b0ea4d8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions server/src/main/java/org/opensearch/index/shard/IndexShard.java
Original file line number Diff line number Diff line change
Expand Up @@ -2356,10 +2356,11 @@ private void innerOpenEngineAndTranslog(LongSupplier globalCheckpointSupplier, b
synchronized (engineMutex) {
assert currentEngineReference.get() == null : "engine is running";
verifyNotClosed();
if (indexSettings.isRemoteStoreEnabled() && syncFromRemote) {
syncSegmentsFromRemoteSegmentStore(false);
}
if (indexSettings.isRemoteTranslogStoreEnabled()) {
if (indexSettings.isRemoteStoreEnabled())
// Download missing segments from remote segment store.
if (syncFromRemote) {
syncSegmentsFromRemoteSegmentStore(false);
}
if (shardRouting.primary()) {
if (syncFromRemote) {
syncRemoteTranslogAndUpdateGlobalCheckpoint();
Expand All @@ -2371,6 +2372,11 @@ private void innerOpenEngineAndTranslog(LongSupplier globalCheckpointSupplier, b
deleteTranslogFilesFromRemoteTranslog();
}
} else if (syncFromRemote) {
// For replicas, when we download segments from remote segment store, we need to make sure that local
// translog is having the same UUID that is referred by the segments. If they are different, engine open
// fails with TranslogCorruptedException. It is safe to create empty translog for remote store enabled
// indices as replica would only need to read translog in failover scenario and we always fetch data
// from remote translog at the time of failover.
final SegmentInfos lastCommittedSegmentInfos = store().readLastCommittedSegmentsInfo();
final String translogUUID = lastCommittedSegmentInfos.userData.get(TRANSLOG_UUID_KEY);
final long checkpoint = Long.parseLong(lastCommittedSegmentInfos.userData.get(SequenceNumbers.LOCAL_CHECKPOINT_KEY));
Expand Down

0 comments on commit b0ea4d8

Please sign in to comment.