From d34596e10c58131c767938817918bdf9f628cb89 Mon Sep 17 00:00:00 2001 From: Suraj Singh Date: Sat, 18 Feb 2023 14:41:25 -0800 Subject: [PATCH] Segment Replication - Recover all translog ops when flipping to writeable engine. (#6352) (#6371) Signed-off-by: Marc Handalian Co-authored-by: Marc Handalian --- .../src/main/java/org/opensearch/index/shard/IndexShard.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index 72ea1c600cc32..dd180b95e6b96 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -4323,7 +4323,9 @@ public void close() throws IOException { // When the new engine is created, translogs are synced from remote store onto local. Since remote store is the source // of truth for translog, we play all translogs that exists locally. Otherwise, the recoverUpto happens upto global checkpoint. - long recoverUpto = this.isRemoteTranslogEnabled() ? Long.MAX_VALUE : globalCheckpoint; + // We also replay all local translog ops with Segment replication, because on engine swap our local translog may + // hold more ops than the global checkpoint. + long recoverUpto = this.isRemoteTranslogEnabled() || indexSettings().isSegRepEnabled() ? Long.MAX_VALUE : globalCheckpoint; newEngineReference.get().recoverFromTranslog(translogRunner, recoverUpto); newEngineReference.get().refresh("reset_engine"); synchronized (engineMutex) {