Skip to content

Commit 8f7fb1d

Browse files
committed
remove commits when remote store is enabled
Signed-off-by: Poojita Raj <[email protected]>
1 parent 95135ec commit 8f7fb1d

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ public synchronized void updateSegments(final SegmentInfos infos) throws IOExcep
157157
// Commit and roll the translog when we receive a different generation than what was last received.
158158
// lower/higher gens are possible from a new primary that was just elected.
159159
if (incomingGeneration != lastReceivedGen) {
160-
commitSegmentInfos();
160+
if (engineConfig.getIndexSettings().isRemoteStoreEnabled() == false) {
161+
commitSegmentInfos();
162+
}
161163
translogManager.getDeletionPolicy().setLocalCheckpointOfSafeCommit(maxSeqNo);
162164
translogManager.rollTranslogGeneration();
163165
}
@@ -397,15 +399,18 @@ protected final void closeNoLock(String reason, CountDownLatch closedLatch) {
397399
assert rwl.isWriteLockedByCurrentThread() || failEngineLock.isHeldByCurrentThread()
398400
: "Either the write lock must be held or the engine must be currently be failing itself";
399401
try {
400-
final SegmentInfos latestSegmentInfos = getLatestSegmentInfos();
401-
/*
402-
This is a workaround solution which decreases the chances of conflict on replica nodes when same file is copied
403-
from two different primaries during failover. Increasing counter helps in avoiding this conflict as counter is
404-
used to generate new segment file names. The ideal solution is to identify the counter from previous primary.
405-
*/
406-
latestSegmentInfos.counter = latestSegmentInfos.counter + SI_COUNTER_INCREMENT;
407-
latestSegmentInfos.changed();
408-
commitSegmentInfos(latestSegmentInfos);
402+
// if remote store is enabled, all segments durably persisted
403+
if (engineConfig.getIndexSettings().isRemoteStoreEnabled() == false) {
404+
final SegmentInfos latestSegmentInfos = getLatestSegmentInfos();
405+
/*
406+
This is a workaround solution which decreases the chances of conflict on replica nodes when same file is copied
407+
from two different primaries during failover. Increasing counter helps in avoiding this conflict as counter is
408+
used to generate new segment file names. The ideal solution is to identify the counter from previous primary.
409+
*/
410+
latestSegmentInfos.counter = latestSegmentInfos.counter + SI_COUNTER_INCREMENT;
411+
latestSegmentInfos.changed();
412+
commitSegmentInfos(latestSegmentInfos);
413+
}
409414
IOUtils.close(readerManager, translogManager, store::decRef);
410415
} catch (Exception e) {
411416
logger.warn("failed to close engine", e);

0 commit comments

Comments
 (0)