248248import static org .apache .cassandra .config .CassandraRelevantProperties .CONSISTENT_RANGE_MOVEMENT ;
249249import static org .apache .cassandra .config .CassandraRelevantProperties .DRAIN_EXECUTOR_TIMEOUT_MS ;
250250import static org .apache .cassandra .config .CassandraRelevantProperties .JOIN_RING ;
251+ import static org .apache .cassandra .config .CassandraRelevantProperties .PAXOS_REPAIR_ON_TOPOLOGY_CHANGE_BY_KEYSPACE ;
251252import static org .apache .cassandra .config .CassandraRelevantProperties .PAXOS_REPAIR_ON_TOPOLOGY_CHANGE_RETRIES ;
252253import static org .apache .cassandra .config .CassandraRelevantProperties .PAXOS_REPAIR_ON_TOPOLOGY_CHANGE_RETRY_DELAY_SECONDS ;
253254import static org .apache .cassandra .config .CassandraRelevantProperties .REPLACE_ADDRESS_FIRST_BOOT ;
@@ -3226,9 +3227,10 @@ public void repairPaxosForTopologyChange(String reason)
32263227 }
32273228
32283229 @ VisibleForTesting
3229- public Future <?> startRepairPaxosForTopologyChange (String reason )
3230+ public Future <?> startRepairPaxosForTopologyChange (String reason ) throws ExecutionException , InterruptedException
32303231 {
32313232 logger .info ("repairing paxos for {}" , reason );
3233+ boolean scheduleByKeyspace = PAXOS_REPAIR_ON_TOPOLOGY_CHANGE_BY_KEYSPACE .getBoolean ();
32323234
32333235 List <Future <?>> futures = new ArrayList <>();
32343236
@@ -3242,7 +3244,11 @@ public Future<?> startRepairPaxosForTopologyChange(String reason)
32423244 continue ;
32433245
32443246 Collection <Range <Token >> ranges = getLocalAndPendingRanges (ksName );
3245- futures .add (ActiveRepairService .instance ().repairPaxosForTopologyChange (ksName , ranges , reason ));
3247+ if (scheduleByKeyspace )
3248+ // blocking wait here if scheduling by keyspace to avoid overwhelming the messages with many repairs at once
3249+ ActiveRepairService .instance ().repairPaxosForTopologyChange (ksName , ranges , reason ).get ();
3250+ else
3251+ futures .add (ActiveRepairService .instance ().repairPaxosForTopologyChange (ksName , ranges , reason ));
32463252 }
32473253
32483254 return FutureCombiner .allOf (futures );
0 commit comments