Handle already closed while filling gaps

We can hit an already closed exception when filling the gaps after
blocking operations when updating the primary term on a promoted replica
shard. We should catch this and suppress it as it is an expected outcome
instead of letting it bubble up which leads to trying to fail the shard
which throws yet another already closed exception.

Relates #25021
This commit is contained in:
Jason Tedor 2017-06-02 08:05:33 -04:00 committed by GitHub
parent 5e7a79636d
commit 7ebba35c32
1 changed files with 5 additions and 1 deletions

View File

@ -370,7 +370,11 @@ public class IndexShard extends AbstractIndexShardComponent implements IndicesCl
TimeUnit.MINUTES,
() -> {
latch.await();
getEngine().fillSeqNoGaps(newPrimaryTerm);
try {
getEngine().fillSeqNoGaps(newPrimaryTerm);
} catch (final AlreadyClosedException e) {
// okay, the index was deleted
}
},
e -> failShard("exception during primary term transition", e));
primaryTerm = newPrimaryTerm;