@@ -500,7 +500,6 @@ func TestChangefeedWithNoDistributionStrategy(t *testing.T) {
500
500
tester := newRangeDistributionTester (t , noLocality )
501
501
defer tester .cleanup ()
502
502
503
- serverutils .SetClusterSetting (t , tester .tc , "changefeed.default_range_distribution_strategy" , "default" )
504
503
serverutils .SetClusterSetting (t , tester .tc , "changefeed.random_replica_selection.enabled" , false )
505
504
tester .sqlDB .Exec (t , "CREATE CHANGEFEED FOR x INTO 'null://' WITH initial_scan='no'" )
506
505
partitions := tester .getPartitions ()
@@ -527,10 +526,9 @@ func TestChangefeedWithSimpleDistributionStrategy(t *testing.T) {
527
526
// Check that we roughly assign (64 ranges / 6 nodes) ranges to each node.
528
527
tester := newRangeDistributionTester (t , noLocality )
529
528
defer tester .cleanup ()
530
- tester .sqlDB .Exec (t , "SET CLUSTER SETTING changefeed.default_range_distribution_strategy = 'balanced_simple'" )
531
529
// We need to disable the bulk oracle in order to ensure the leaseholder is selected.
532
530
tester .sqlDB .Exec (t , "SET CLUSTER SETTING changefeed.random_replica_selection.enabled = false" )
533
- tester .sqlDB .Exec (t , "CREATE CHANGEFEED FOR x INTO 'null://' WITH initial_scan='no'" )
531
+ tester .sqlDB .Exec (t , "CREATE CHANGEFEED FOR x INTO 'null://' WITH initial_scan='no', range_distribution_strategy='balanced_simple' " )
534
532
partitions := tester .getPartitions ()
535
533
counts := tester .countRangesPerNode (partitions )
536
534
upper := int (math .Ceil ((1 + rebalanceThreshold .Get (& tester .lastNode .ClusterSettings ().SV )) * 64 / 6 ))
@@ -548,30 +546,56 @@ func TestChangefeedWithNoDistributionStrategyAndConstrainedLocality(t *testing.T
548
546
skip .UnderShort (t )
549
547
skip .UnderDuress (t )
550
548
551
- // The replica oracle selects the leaseholder replica for each range. Then, distsql assigns the replica
552
- // to the same node which stores it. However, node of these nodes don't pass the filter. The replicas assigned
553
- // to these nodes are distributed arbitrarily to any nodes which pass the filter.
554
- tester := newRangeDistributionTester (t , func (i int ) []roachpb.Tier {
555
- if i % 2 == 1 {
556
- return []roachpb.Tier {{Key : "y" , Value : "1" }}
549
+ t .Run ("default specified" , func (t * testing.T ) {
550
+ // The replica oracle selects the leaseholder replica for each range. Then, distsql assigns the replica
551
+ // to the same node which stores it. However, node of these nodes don't pass the filter. The replicas assigned
552
+ // to these nodes are distributed arbitrarily to any nodes which pass the filter.
553
+ tester := newRangeDistributionTester (t , func (i int ) []roachpb.Tier {
554
+ if i % 2 == 1 {
555
+ return []roachpb.Tier {{Key : "y" , Value : "1" }}
556
+ }
557
+ return []roachpb.Tier {}
558
+ })
559
+ defer tester .cleanup ()
560
+ tester .sqlDB .Exec (t , "CREATE CHANGEFEED FOR x INTO 'null://' WITH initial_scan='no', execution_locality='y=1', range_distribution_strategy='default'" )
561
+ partitions := tester .getPartitions ()
562
+ counts := tester .countRangesPerNode (partitions )
563
+
564
+ totalRanges := 0
565
+ for i , count := range counts {
566
+ if i % 2 == 1 {
567
+ totalRanges += count
568
+ } else {
569
+ require .Equal (t , count , 0 )
570
+ }
557
571
}
558
- return []roachpb. Tier {}
572
+ require . Equal ( t , totalRanges , 64 )
559
573
})
560
- defer tester .cleanup ()
561
- tester .sqlDB .Exec (t , "SET CLUSTER SETTING changefeed.default_range_distribution_strategy = 'default'" )
562
- tester .sqlDB .Exec (t , "CREATE CHANGEFEED FOR x INTO 'null://' WITH initial_scan='no', execution_locality='y=1'" )
563
- partitions := tester .getPartitions ()
564
- counts := tester .countRangesPerNode (partitions )
565
-
566
- totalRanges := 0
567
- for i , count := range counts {
568
- if i % 2 == 1 {
569
- totalRanges += count
570
- } else {
571
- require .Equal (t , count , 0 )
574
+ t .Run ("no distribution strategy specified" , func (t * testing.T ) {
575
+ // The replica oracle selects the leaseholder replica for each range. Then, distsql assigns the replica
576
+ // to the same node which stores it. However, node of these nodes don't pass the filter. The replicas assigned
577
+ // to these nodes are distributed arbitrarily to any nodes which pass the filter.
578
+ tester := newRangeDistributionTester (t , func (i int ) []roachpb.Tier {
579
+ if i % 2 == 1 {
580
+ return []roachpb.Tier {{Key : "y" , Value : "1" }}
581
+ }
582
+ return []roachpb.Tier {}
583
+ })
584
+ defer tester .cleanup ()
585
+ tester .sqlDB .Exec (t , "CREATE CHANGEFEED FOR x INTO 'null://' WITH initial_scan='no', execution_locality='y=1'" )
586
+ partitions := tester .getPartitions ()
587
+ counts := tester .countRangesPerNode (partitions )
588
+
589
+ totalRanges := 0
590
+ for i , count := range counts {
591
+ if i % 2 == 1 {
592
+ totalRanges += count
593
+ } else {
594
+ require .Equal (t , count , 0 )
595
+ }
572
596
}
573
- }
574
- require . Equal ( t , totalRanges , 64 )
597
+ require . Equal ( t , totalRanges , 64 )
598
+ } )
575
599
}
576
600
577
601
func TestChangefeedWithSimpleDistributionStrategyAndConstrainedLocality (t * testing.T ) {
@@ -593,8 +617,7 @@ func TestChangefeedWithSimpleDistributionStrategyAndConstrainedLocality(t *testi
593
617
return []roachpb.Tier {}
594
618
})
595
619
defer tester .cleanup ()
596
- tester .sqlDB .Exec (t , "SET CLUSTER SETTING changefeed.default_range_distribution_strategy = 'balanced_simple'" )
597
- tester .sqlDB .Exec (t , "CREATE CHANGEFEED FOR x INTO 'null://' WITH initial_scan='no', execution_locality='y=1'" )
620
+ tester .sqlDB .Exec (t , "CREATE CHANGEFEED FOR x INTO 'null://' WITH initial_scan='no', execution_locality='y=1', range_distribution_strategy='balanced_simple'" )
598
621
partitions := tester .getPartitions ()
599
622
counts := tester .countRangesPerNode (partitions )
600
623
0 commit comments