Skip to content

Commit

Permalink
Add primary mode check before assserting on primary mode.
Browse files Browse the repository at this point in the history
Signed-off-by: Rishikesh1159 <[email protected]>
  • Loading branch information
Rishikesh1159 committed Oct 18, 2023
1 parent e942483 commit 6656af2
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,17 @@ public synchronized void sendFiles(GetSegmentFilesRequest request, ActionListene
);
};
cancellableThreads.checkForCancel();
final IndexShardRoutingTable routingTable = shard.getReplicationGroup().getRoutingTable();
ShardRouting targetShardRouting = routingTable.getByAllocationId(request.getTargetAllocationId());
if (targetShardRouting == null) {
logger.debug("delaying replication of {} as it is not listed as assigned to target node {}", shard.shardId(), targetNode);
throw new DelayRecoveryException("source node does not have the shard listed in its state as allocated on the node");
if (shard.isPrimaryMode()) {
final IndexShardRoutingTable routingTable = shard.getReplicationGroup().getRoutingTable();
ShardRouting targetShardRouting = routingTable.getByAllocationId(request.getTargetAllocationId());
if (targetShardRouting == null) {
logger.debug(
"delaying replication of {} as it is not listed as assigned to target node {}",
shard.shardId(),
targetNode
);
throw new DelayRecoveryException("source node does not have the shard listed in its state as allocated on the node");
}
}

final StepListener<Void> sendFileStep = new StepListener<>();
Expand Down

0 comments on commit 6656af2

Please sign in to comment.