Handle AlreadyClosedException when bumping primary term

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
This commit is contained in:
Yannick Welsch 2018-08-06 08:34:38 +02:00
parent 66edba2012
commit 3cf08326ab
1 changed files with 7 additions and 1 deletions

View File

@ -2229,7 +2229,13 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
onBlocked.run(); 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; pendingPrimaryTerm = newPrimaryTerm;
termUpdated.countDown(); termUpdated.countDown();
} }