pvcnt commented on code in PR #2039:
URL: https://github.com/apache/solr/pull/2039#discussion_r1410733136
##########
solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java:
##########
@@ -590,12 +589,22 @@ public static List<String> populateShardNames(ZkNodeProps
message, String router
return shardNames;
}
- private static ReplicaCount getNumReplicas(ZkNodeProps message) {
- int numTlogReplicas = message.getInt(TLOG_REPLICAS, 0);
- int numNrtReplicas =
- message.getInt(
- NRT_REPLICAS, message.getInt(REPLICATION_FACTOR, numTlogReplicas >
0 ? 0 : 1));
- return new ReplicaCount(numNrtReplicas, numTlogReplicas,
message.getInt(PULL_REPLICAS, 0));
+ private ReplicaCount getNumReplicas(ZkNodeProps message) {
+ ReplicaCount numReplicas = ReplicaCount.fromMessage(message);
+ int numLeaderEligibleReplicas =
numReplicas.count(leaderEligibleReplicaTypes);
+ if (numLeaderEligibleReplicas == 0 &&
!numReplicas.contains(Replica.Type.defaultType())) {
+ // Ensure that there is at least one replica that can become leader if
the user did
+ // not force a replica count.
+ numReplicas.put(Replica.Type.defaultType(), 1);
+ } else if (numLeaderEligibleReplicas == 0) {
+ // This can still fail if the user manually forced "0" replica counts.
Review Comment:
The current behaviour is:
- if I pass no parameters, I will have 1 NRT replica
- if I pass `pullReplicas=1`, I will have 1 NRT and 1 PULL replica
- if I pass `nrtReplicas=0`, I will have an error
What you are suggesting is to change the third situation, and instead to
silently transform the user request into `nrtReplicas=1`. The error is
triggered if the default replica type is explicitly set to 0, not if all
replica types are set to 0.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]