File tree Expand file tree Collapse file tree
server/src/main/java/org/opensearch Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5293,7 +5293,7 @@ public void close() throws IOException {
52935293 assert translogManager instanceof InternalTranslogManager ;
52945294 long localCheckpoint = engine .getProcessedLocalCheckpoint ();
52955295 List <Tuple <Future <Integer >, Translog .Snapshot >> translogSnapshotsFutureList = new ArrayList <>();
5296- for (int i = 0 ; i <= totalOperations / batchSize ; i ++) {
5296+ for (int i = 0 ; i < ( totalOperations + batchSize - 1 ) / batchSize ; i ++) {
52975297 long start = localCheckpoint + 1 + (long ) i * batchSize ;
52985298 long end = (i == totalOperations / batchSize ) ? Long .MAX_VALUE : start + batchSize - 1 ;
52995299 Translog .Snapshot translogSnapshot = ((InternalTranslogManager ) translogManager ).getTranslog ().newSnapshot (start , end );
@@ -5312,15 +5312,16 @@ public void close() throws IOException {
53125312 for (Tuple <Future <Integer >, Translog .Snapshot > translogSnapshotFuture : translogSnapshotsFutureList ) {
53135313 try {
53145314 int recoveredOps = translogSnapshotFuture .v1 ().get ();
5315- Translog .Snapshot translogSnapshot = translogSnapshotFuture .v2 ();
5316- translogSnapshot .close ();
53175315 totalRecovered += recoveredOps ;
53185316 } catch (Exception e ) {
53195317 if (exception == null ) {
53205318 exception = e ;
53215319 } else {
53225320 exception .addSuppressed (e );
53235321 }
5322+ } finally {
5323+ Translog .Snapshot translogSnapshot = translogSnapshotFuture .v2 ();
5324+ IOUtils .closeWhileHandlingException (translogSnapshot );
53245325 }
53255326 }
53265327 if (exception != null ) {
Original file line number Diff line number Diff line change @@ -240,6 +240,7 @@ public class RecoverySettings {
240240 public static final Setting <Long > INDICES_TRANSLOG_CONCURRENT_RECOVERY_BATCH_SIZE = Setting .longSetting (
241241 "indices.translog_concurrent_recovery.batch_size" ,
242242 50000 ,
243+ 1 ,
243244 Property .Dynamic ,
244245 Property .NodeScope
245246 );
You can’t perform that action at this time.
0 commit comments