diff --git a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java index 5b7ba93405d61..9bf6f24a9015d 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/index/seqno/GlobalCheckpointSyncIT.java @@ -8,6 +8,7 @@ package org.elasticsearch.index.seqno; +import org.apache.lucene.store.AlreadyClosedException; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; @@ -194,12 +195,21 @@ private void runGlobalCheckpointSyncTest( for (IndexService indexService : indicesService) { for (IndexShard shard : indexService) { if (shard.routingEntry().primary()) { - final SeqNoStats seqNoStats = shard.seqNoStats(); - assertThat( - "shard " + shard.routingEntry() + " seq_no [" + seqNoStats + "]", - seqNoStats.getGlobalCheckpoint(), - equalTo(seqNoStats.getMaxSeqNo()) - ); + try { + final SeqNoStats seqNoStats = shard.seqNoStats(); + assertThat( + "shard " + shard.routingEntry() + " seq_no [" + seqNoStats + "]", + seqNoStats.getGlobalCheckpoint(), + equalTo(seqNoStats.getMaxSeqNo()) + ); + } catch (AlreadyClosedException e) { + logger.error( + "received unexpected AlreadyClosedException when fetching stats for shard: {}, shard state: {}", + shard.shardId(), + shard.state() + ); + throw e; + } } } }