Skip to content

Commit 3228189

Browse files
jxie-1ncordon
authored andcommitted
Check relocating node id when finding source for reshard recovery (elastic#137848)
* Check relocating node id when finding source for reshard recovery * Explicit return null
1 parent bfc83f2 commit 3228189

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

server/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,18 @@ private static DiscoveryNode findSourceNodeForReshardSplitRecovery(
10461046
return null;
10471047
}
10481048

1049+
if (sourceShardRouting.relocatingNodeId() != null) {
1050+
DiscoveryNode sourceNode = nodes.get(sourceShardRouting.relocatingNodeId());
1051+
if (sourceNode == null) {
1052+
logger.trace(
1053+
"can't find relocation reshard split source node for shard {} because it is assigned to an unknown node [{}].",
1054+
sourceShardRouting.shardId(),
1055+
sourceShardRouting.relocatingNodeId()
1056+
);
1057+
return null;
1058+
}
1059+
return sourceNode;
1060+
}
10491061
DiscoveryNode sourceNode = nodes.get(sourceShardRouting.currentNodeId());
10501062
if (sourceNode == null) {
10511063
assert false : "Source node for reshard does not exist: " + sourceShardRouting.currentNodeId();

0 commit comments

Comments
 (0)