@@ -617,7 +617,7 @@ func checkReplicaCount(
617617 rangeDesc * roachpb.RangeDescriptor ,
618618 voterCount , nonVoterCount int ,
619619) (bool , error ) {
620- err := forceScanOnAllReplicationQueues (tc )
620+ err := forceScanOnAllReplicationAndSplitQueues (tc )
621621 if err != nil {
622622 log .KvDistribution .Infof (ctx , "store.ForceReplicationScanAndProcess() failed with: %s" , err )
623623 return false , err
@@ -1543,7 +1543,7 @@ func TestReplicateQueueSwapVotersWithNonVoters(t *testing.T) {
15431543 " num_replicas=5, num_voters=1" )
15441544 require .NoError (t , err )
15451545 testutils .SucceedsSoon (t , func () error {
1546- if err := forceScanOnAllReplicationQueues (tc ); err != nil {
1546+ if err := forceScanOnAllReplicationAndSplitQueues (tc ); err != nil {
15471547 return err
15481548 }
15491549 scratchRange := tc .LookupRangeOrFatal (t , scratchKey )
@@ -1558,7 +1558,7 @@ func TestReplicateQueueSwapVotersWithNonVoters(t *testing.T) {
15581558
15591559 checkRelocated := func (t * testing.T , voterStores , nonVoterStores []roachpb.StoreID ) {
15601560 testutils .SucceedsSoon (t , func () error {
1561- if err := forceScanOnAllReplicationQueues (tc ); err != nil {
1561+ if err := forceScanOnAllReplicationAndSplitQueues (tc ); err != nil {
15621562 return err
15631563 }
15641564 scratchRange := tc .LookupRangeOrFatal (t , scratchKey )
@@ -1664,7 +1664,7 @@ func TestReplicateQueueShouldQueueNonVoter(t *testing.T) {
16641664 // Make sure that the range has conformed to the constraints we just set
16651665 // above.
16661666 require .Eventually (t , func () bool {
1667- if err := forceScanOnAllReplicationQueues (tc ); err != nil {
1667+ if err := forceScanOnAllReplicationAndSplitQueues (tc ); err != nil {
16681668 log .KvDistribution .Warningf (ctx , "received error while forcing a replicateQueue scan: %s" , err )
16691669 return false
16701670 }
@@ -1784,10 +1784,19 @@ func toggleReplicationQueues(tc *testcluster.TestCluster, active bool) {
17841784 }
17851785}
17861786
1787- func forceScanOnAllReplicationQueues (tc * testcluster.TestCluster ) (err error ) {
1787+ func forceScanOnAllReplicationAndSplitQueues (tc * testcluster.TestCluster ) (err error ) {
1788+ // We force scans on the replication and split queues because sometimes splits
1789+ // are necessary to apply zone config changes, which then lead to further
1790+ // replication decisions. See #156530 for an example of this.
17881791 for _ , s := range tc .Servers {
17891792 if err := s .GetStores ().(* kvserver.Stores ).VisitStores (func (store * kvserver.Store ) error {
1790- return store .ForceReplicationScanAndProcess ()
1793+ if err := store .ForceReplicationScanAndProcess (); err != nil {
1794+ return err
1795+ }
1796+ if err := store .ForceSplitScanAndProcess (); err != nil {
1797+ return err
1798+ }
1799+ return nil
17911800 }); err != nil {
17921801 return err
17931802 }
@@ -2231,7 +2240,7 @@ func TestPromoteNonVoterInAddVoter(t *testing.T) {
22312240 setConstraintFn ("RANGE meta" , 7 , 7 , "" )
22322241 setConstraintFn ("RANGE default" , 7 , 7 , "" )
22332242 testutils .SucceedsSoon (t , func () error {
2234- if err := forceScanOnAllReplicationQueues (tc ); err != nil {
2243+ if err := forceScanOnAllReplicationAndSplitQueues (tc ); err != nil {
22352244 return err
22362245 }
22372246 s , err := sqlutils .RowsToDataDrivenOutput (sqlutils .MakeSQLRunner (tc .Conns [0 ]).Query (t , `
@@ -2266,7 +2275,7 @@ SELECT * FROM (
22662275 tc * testcluster.TestCluster ,
22672276 db * gosql.DB ,
22682277 ) (numVoters , numNonVoters int , _ roachpb.RangeID , err error ) {
2269- if err := forceScanOnAllReplicationQueues (tc ); err != nil {
2278+ if err := forceScanOnAllReplicationAndSplitQueues (tc ); err != nil {
22702279 return 0 , 0 , 0 , err
22712280 }
22722281
0 commit comments