Skip to content

Commit

Permalink
Fix PIT when resolving with deleted indices (elastic#99281) (elastic#…
Browse files Browse the repository at this point in the history
…99330)

* Fix PIT when resolving with deleted indices

* Update docs/changelog/99281.yaml
  • Loading branch information
dnhatn authored Sep 7, 2023
1 parent 2568ff8 commit 2af8eb7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions docs/changelog/99281.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 99281
summary: Fix PIT when resolving with deleted indices
area: Search
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -1348,12 +1348,12 @@ static List<SearchShardIterator> getLocalLocalShardsIteratorFromPointInTime(
if (Strings.isEmpty(perNode.getClusterAlias())) {
final ShardId shardId = entry.getKey();
final List<String> targetNodes = new ArrayList<>(2);
// Prefer executing shard requests on nodes that are part of PIT first.
if (clusterState.nodes().nodeExists(perNode.getNode())) {
targetNodes.add(perNode.getNode());
}
try {
final ShardIterator shards = OperationRouting.getShards(clusterState, shardId);
// Prefer executing shard requests on nodes that are part of PIT first.
if (clusterState.nodes().nodeExists(perNode.getNode())) {
targetNodes.add(perNode.getNode());
}
if (perNode.getSearchContextId().getSearcherId() != null) {
for (ShardRouting shard : shards) {
if (shard.currentNodeId().equals(perNode.getNode()) == false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,7 @@ public void testLocalShardIteratorFromPointInTime() {
true
).stream().filter(si -> si.shardId().equals(anotherShardId)).findFirst();
assertTrue(anotherShardIterator.isPresent());
assertThat(anotherShardIterator.get().getTargetNodeIds(), hasSize(1));
assertThat(anotherShardIterator.get().getTargetNodeIds(), hasSize(0));
}

public void testCCSCompatibilityCheck() throws Exception {
Expand Down

0 comments on commit 2af8eb7

Please sign in to comment.