|
@@ -188,7 +188,8 @@ public abstract class ReplicaShardAllocator extends BaseGatewayShardAllocator {
|
|
|
} else if (matchingNodes.getNodeWithHighestMatch() != null) {
|
|
|
RoutingNode nodeWithHighestMatch = allocation.routingNodes().node(matchingNodes.getNodeWithHighestMatch().getId());
|
|
|
// we only check on THROTTLE since we checked before on NO
|
|
|
- Decision decision = allocation.deciders().canAllocate(unassignedShard, nodeWithHighestMatch, allocation);
|
|
|
+ Decision decision = allocation.deciders().canAllocateReplicaWhenThereIsRetentionLease(unassignedShard,
|
|
|
+ nodeWithHighestMatch, allocation);
|
|
|
if (decision.type() == Decision.Type.THROTTLE) {
|
|
|
logger.debug("[{}][{}]: throttling allocation [{}] to [{}] in order to reuse its unallocated persistent store",
|
|
|
unassignedShard.index(), unassignedShard.id(), unassignedShard, nodeWithHighestMatch.node());
|
|
@@ -245,7 +246,7 @@ public abstract class ReplicaShardAllocator extends BaseGatewayShardAllocator {
|
|
|
}
|
|
|
// if we can't allocate it on a node, ignore it, for example, this handles
|
|
|
// cases for only allocating a replica after a primary
|
|
|
- Decision decision = allocation.deciders().canAllocate(shard, node, allocation);
|
|
|
+ Decision decision = allocation.deciders().canAllocateReplicaWhenThereIsRetentionLease(shard, node, allocation);
|
|
|
if (decision.type() == Decision.Type.YES && madeDecision.type() != Decision.Type.YES) {
|
|
|
if (explain) {
|
|
|
madeDecision = decision;
|
|
@@ -317,10 +318,17 @@ public abstract class ReplicaShardAllocator extends BaseGatewayShardAllocator {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- // check if we can allocate on that node...
|
|
|
- // we only check for NO, since if this node is THROTTLING and it has enough "same data"
|
|
|
- // then we will try and assign it next time
|
|
|
- Decision decision = allocation.deciders().canAllocate(shard, node, allocation);
|
|
|
+ // Check whether we have existing data for the replica
|
|
|
+ final long retainingSeqNoForReplica = primaryStore.getPeerRecoveryRetentionLeaseRetainingSeqNo(discoNode);
|
|
|
+ final Decision decision;
|
|
|
+ if (retainingSeqNoForReplica == -1) {
|
|
|
+ // There is no existing replica data on the node
|
|
|
+ decision = allocation.deciders().canAllocate(shard, node, allocation);
|
|
|
+ } else {
|
|
|
+ // There is existing replica data on the node
|
|
|
+ decision = allocation.deciders().canAllocateReplicaWhenThereIsRetentionLease(shard, node, allocation);
|
|
|
+ }
|
|
|
+
|
|
|
MatchingNode matchingNode = null;
|
|
|
if (explain) {
|
|
|
matchingNode = computeMatchingNode(primaryNode, primaryStore, discoNode, storeFilesMetadata);
|
|
@@ -328,6 +336,8 @@ public abstract class ReplicaShardAllocator extends BaseGatewayShardAllocator {
|
|
|
nodeDecisions.put(node.nodeId(), new NodeAllocationResult(discoNode, shardStoreInfo, decision));
|
|
|
}
|
|
|
|
|
|
+ // we only check for NO, since if this node is THROTTLING and it has enough "same data"
|
|
|
+ // then we will try and assign it next time
|
|
|
if (decision.type() == Decision.Type.NO) {
|
|
|
continue;
|
|
|
}
|