Skip to content

Commit 7b6c2a0

Browse files
committed
Deal with exceptions when obtaining both retention locks
1 parent c8d2bf9 commit 7b6c2a0

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

server/src/main/java/org/elasticsearch/index/engine/InternalEngine.java

+16-3
Original file line numberDiff line numberDiff line change
@@ -2567,10 +2567,23 @@ public final long getMinRetainedSeqNo() {
25672567
public Closeable acquireRetentionLock() {
25682568
if (softDeleteEnabled) {
25692569
final Closeable softDeletesRetentionLock = softDeletesPolicy.acquireRetentionLock();
2570-
final Closeable translogRetentionLock = translog.acquireRetentionLock();
2570+
final Closeable translogRetentionLock;
2571+
try {
2572+
translogRetentionLock = translog.acquireRetentionLock();
2573+
} catch (Exception e) {
2574+
try {
2575+
softDeletesRetentionLock.close();
2576+
} catch (IOException ioexception) {
2577+
e.addSuppressed(ioexception);
2578+
}
2579+
throw e;
2580+
}
25712581
return () -> {
2572-
softDeletesRetentionLock.close();
2573-
translogRetentionLock.close();
2582+
try {
2583+
translogRetentionLock.close();
2584+
} finally {
2585+
softDeletesRetentionLock.close();
2586+
}
25742587
};
25752588
} else {
25762589
return translog.acquireRetentionLock();

0 commit comments

Comments
 (0)