cockroach
cockroach copied to clipboard
release-23.1: kvserver: rebalance ranges with one voter using joint configurations
Backport 1/2 commits from #124284 on behalf of @kvoli.
The first commit 1fe25bc3296a1a814e90ec45930acf9ee1fad786 is omitted, as the simulator did not reproduce thrashing on this release.
/cc @cockroachdb/release
The allocator would add a voter, instead of both adding and removing the existing voter when rebalancing ranges with one replica. Removing the leaseholder replica was not possible prior to https://github.com/cockroachdb/cockroach/pull/74077, so the addition only was necessary.
This restriction is no longer necessary. Allow rebalancing a one voter range between stores using joint configurations, where the lease will be transferred to the incoming voter store, from the outgoing demoting voter.
Scattering ranges with one voter will now leave the range with exactly one voter, where previously both the leaseholder voter evaluating the scatter, and the new voter would be left.
Before this patch, scattering 1000 ranges with RF=1 on a 5 store cluster:
store_id | replica_count | replica_distribution | lease_count | lease_distribution
-----------+---------------+----------------------+-------------+---------------------
1 | 1001 | ########## | 500 | ##########
5 | 291 | ### | 147 | ###
4 | 275 | ### | 137 | ###
3 | 229 | ### | 118 | ###
2 | 206 | ### | 99 | ##
After:
store_id | replica_count | replica_distribution | lease_count | lease_distribution
-----------+---------------+----------------------+-------------+---------------------
2 | 242 | ########## | 241 | ##########
4 | 227 | ########## | 227 | ##########
5 | 217 | ######### | 216 | #########
3 | 209 | ######### | 208 | #########
1 | 106 | ##### | 109 | #####
Fixes: https://github.com/cockroachdb/cockroach/issues/108420 Fixes: https://github.com/cockroachdb/cockroach/issues/124171
Release note (bug fix): Scattering a range with replication factor=1, no longer erroneously up-replicates the range to two replicas. Leases will also no longer thrash between nodes when perturbed with replication factor=1.
Release justification: Fixes o-support
bug that hinders RESTORE progress when RF=1.