Skip to content

Commit 232d2e0

Browse files
committed
Catch AlreadyClosedException and use other IndexShard instance (#38630)
Closes #38617
1 parent 5cea933 commit 232d2e0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/CcrIntegTestCase.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,14 @@ private Map<Integer, List<DocIdSeqNoAndTerm>> getDocIdAndSeqNos(InternalTestClus
491491
}
492492
IndexShard indexShard = cluster.getInstance(IndicesService.class, state.nodes().get(shardRouting.currentNodeId()).getName())
493493
.indexServiceSafe(shardRouting.index()).getShard(shardRouting.id());
494-
docs.put(shardRouting.shardId().id(), IndexShardTestCase.getDocIdAndSeqNos(indexShard).stream()
495-
.map(d -> new DocIdSeqNoAndTerm(d.getId(), d.getSeqNo(), 1L)) // normalize primary term as the follower use its own term
496-
.collect(Collectors.toList()));
494+
try {
495+
docs.put(shardRouting.shardId().id(), IndexShardTestCase.getDocIdAndSeqNos(indexShard).stream()
496+
// normalize primary term as the follower use its own term
497+
.map(d -> new DocIdSeqNoAndTerm(d.getId(), d.getSeqNo(), 1L))
498+
.collect(Collectors.toList()));
499+
} catch (AlreadyClosedException e) {
500+
// Ignore this exception and try getting List<DocIdSeqNoAndTerm> from other IndexShard instance.
501+
}
497502
}
498503
return docs;
499504
}

0 commit comments

Comments
 (0)