Skip to content

Commit 84353a6

Browse files
committed
Catch AlreadyClosedException and use other IndexShard instance (#38630)
Closes #38617
1 parent 9e95821 commit 84353a6

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
@@ -487,9 +487,14 @@ private Map<Integer, List<DocIdSeqNoAndTerm>> getDocIdAndSeqNos(InternalTestClus
487487
}
488488
IndexShard indexShard = cluster.getInstance(IndicesService.class, state.nodes().get(shardRouting.currentNodeId()).getName())
489489
.indexServiceSafe(shardRouting.index()).getShard(shardRouting.id());
490-
docs.put(shardRouting.shardId().id(), IndexShardTestCase.getDocIdAndSeqNos(indexShard).stream()
491-
.map(d -> new DocIdSeqNoAndTerm(d.getId(), d.getSeqNo(), 1L)) // normalize primary term as the follower use its own term
492-
.collect(Collectors.toList()));
490+
try {
491+
docs.put(shardRouting.shardId().id(), IndexShardTestCase.getDocIdAndSeqNos(indexShard).stream()
492+
// normalize primary term as the follower use its own term
493+
.map(d -> new DocIdSeqNoAndTerm(d.getId(), d.getSeqNo(), 1L))
494+
.collect(Collectors.toList()));
495+
} catch (AlreadyClosedException e) {
496+
// Ignore this exception and try getting List<DocIdSeqNoAndTerm> from other IndexShard instance.
497+
}
493498
}
494499
return docs;
495500
}

0 commit comments

Comments
 (0)