@@ -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