Catch AlreadyClosedException and use other IndexShard instance (#38630)

Closes #38617
This commit is contained in:
Martijn van Groningen 2019-02-11 15:35:39 +01:00
parent 884b5063a4
commit 92201ef563
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
1 changed files with 8 additions and 3 deletions

View File

@ -487,9 +487,14 @@ public abstract class CcrIntegTestCase extends ESTestCase {
}
IndexShard indexShard = cluster.getInstance(IndicesService.class, state.nodes().get(shardRouting.currentNodeId()).getName())
.indexServiceSafe(shardRouting.index()).getShard(shardRouting.id());
docs.put(shardRouting.shardId().id(), IndexShardTestCase.getDocIdAndSeqNos(indexShard).stream()
.map(d -> new DocIdSeqNoAndTerm(d.getId(), d.getSeqNo(), 1L)) // normalize primary term as the follower use its own term
.collect(Collectors.toList()));
try {
docs.put(shardRouting.shardId().id(), IndexShardTestCase.getDocIdAndSeqNos(indexShard).stream()
// normalize primary term as the follower use its own term
.map(d -> new DocIdSeqNoAndTerm(d.getId(), d.getSeqNo(), 1L))
.collect(Collectors.toList()));
} catch (AlreadyClosedException e) {
// Ignore this exception and try getting List<DocIdSeqNoAndTerm> from other IndexShard instance.
}
}
return docs;
}