Skip to content

Commit

Permalink
Deal with exceptions when obtaining both retention locks
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveCTurner committed Feb 14, 2019
1 parent c8d2bf9 commit 7b6c2a0
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2567,10 +2567,23 @@ public final long getMinRetainedSeqNo() {
public Closeable acquireRetentionLock() {
if (softDeleteEnabled) {
final Closeable softDeletesRetentionLock = softDeletesPolicy.acquireRetentionLock();
final Closeable translogRetentionLock = translog.acquireRetentionLock();
final Closeable translogRetentionLock;
try {
translogRetentionLock = translog.acquireRetentionLock();
} catch (Exception e) {
try {
softDeletesRetentionLock.close();
} catch (IOException ioexception) {
e.addSuppressed(ioexception);
}
throw e;
}
return () -> {
softDeletesRetentionLock.close();
translogRetentionLock.close();
try {
translogRetentionLock.close();
} finally {
softDeletesRetentionLock.close();
}
};
} else {
return translog.acquireRetentionLock();
Expand Down

0 comments on commit 7b6c2a0

Please sign in to comment.