Skip to content

Commit ad8564b

Browse files
committed
update
Signed-off-by: guojialiang <guojialiang.2012@bytedance.com>
1 parent ac424e3 commit ad8564b

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

server/src/main/java/org/opensearch/index/shard/IndexShard.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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) {

server/src/main/java/org/opensearch/indices/recovery/RecoverySettings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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
);

0 commit comments

Comments
 (0)