Skip to content

Commit

Permalink
Handle AlreadyClosedException when bumping primary term
Browse files Browse the repository at this point in the history
If the shard is already closed while bumping the primary term, this can result in an
AlreadyClosedException to be thrown. As we use asyncBlockOperations, the exception
will be thrown on a thread from the generic thread pool and end up in the uncaught
exception handler, failing our tests.

Relates to #32442
  • Loading branch information
ywelsch committed Aug 6, 2018
1 parent 66edba2 commit 3cf0832
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2229,7 +2229,13 @@ private <E extends Exception> void bumpPrimaryTerm(long newPrimaryTerm, final Ch
onBlocked.run();
}
},
e -> failShard("exception during primary term transition", e));
e -> {
try {
failShard("exception during primary term transition", e);
} catch (AlreadyClosedException ace) {
// ignore, shard is already closed
}
});
pendingPrimaryTerm = newPrimaryTerm;
termUpdated.countDown();
}
Expand Down

0 comments on commit 3cf0832

Please sign in to comment.