Skip to content

Commit

Permalink
sql: use global_reads for GLOBAL tables
Browse files Browse the repository at this point in the history
This commit enables global_reads for tables with the GLOBAL locality
config. global_reads are not yet hooked up in KV because we don't yet
have per-range closed timestamp tracking, but this completes the
SQL-level work for GLOBAL tables, with the exception of #57663, which
will add non-voting replicas (at the database zone config level) for all
database regions that don't already have a voting replica.

Release note: None
  • Loading branch information
nvanbenschoten committed Jan 27, 2021
1 parent 86d94aa commit 91fbbca
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/ccl/logictestccl/testdata/logic_test/alter_table_locality
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ TABLE global ALTER TABLE global CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
global_reads = true,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'
Expand Down Expand Up @@ -219,6 +220,7 @@ TABLE global ALTER TABLE global CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
global_reads = true,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'
Expand Down Expand Up @@ -337,6 +339,7 @@ TABLE regional_by_table_in_primary_region ALTER TABLE regional_by_table_in_prim
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
global_reads = true,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'
Expand Down Expand Up @@ -450,6 +453,7 @@ TABLE regional_by_table_no_region ALTER TABLE regional_by_table_no_region CONFI
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
global_reads = true,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'
Expand Down Expand Up @@ -555,6 +559,7 @@ TABLE regional_by_table_in_us_east ALTER TABLE regional_by_table_in_us_east CON
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
global_reads = true,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'
Expand Down
4 changes: 4 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/multiregion
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ TABLE global_table ALTER TABLE global_table CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
global_reads = true,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'
Expand Down Expand Up @@ -582,6 +583,7 @@ TABLE t_global ALTER TABLE t_global CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
global_reads = true,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'
Expand Down Expand Up @@ -663,6 +665,7 @@ TABLE t_global ALTER TABLE t_global CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
global_reads = true,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'
Expand Down Expand Up @@ -716,6 +719,7 @@ TABLE t_global ALTER TABLE t_global CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
global_reads = true,
num_replicas = 3,
constraints = '{+region=ap-southeast-2: 1, +region=ca-central-1: 1, +region=us-east-1: 1}',
lease_preferences = '[[+region=ca-central-1]]'
4 changes: 3 additions & 1 deletion pkg/sql/region_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ func zoneConfigFromTableLocalityConfig(

switch l := localityConfig.Locality.(type) {
case *descpb.TableDescriptor_LocalityConfig_Global_:
// Inherit everything from the database.
// Enable non-blocking transactions.
ret.GlobalReads = proto.Bool(true)
// Inherit constraints and leaseholders from the database.
ret.InheritedConstraints = true
ret.InheritedLeasePreferences = true
case *descpb.TableDescriptor_LocalityConfig_RegionalByTable_:
Expand Down
4 changes: 3 additions & 1 deletion pkg/sql/region_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ func TestZoneConfigFromTableLocalityConfig(t *testing.T) {
SurvivalGoal: descpb.SurvivalGoal_ZONE_FAILURE,
},
expected: &zonepb.ZoneConfig{
GlobalReads: proto.Bool(true),
NumReplicas: proto.Int32(4),
InheritedConstraints: true,
InheritedLeasePreferences: true,
Expand All @@ -228,6 +229,7 @@ func TestZoneConfigFromTableLocalityConfig(t *testing.T) {
SurvivalGoal: descpb.SurvivalGoal_REGION_FAILURE,
},
expected: &zonepb.ZoneConfig{
GlobalReads: proto.Bool(true),
NumReplicas: proto.Int32(4),
InheritedConstraints: true,
InheritedLeasePreferences: true,
Expand Down Expand Up @@ -434,7 +436,7 @@ func TestZoneConfigFromRegionConfigForPartition(t *testing.T) {
},
},
{
desc: "4-region global table with region survivability",
desc: "4-region table with region survivability",
region: descpb.DatabaseDescriptor_RegionConfig_Region{
Name: "region_a",
},
Expand Down

0 comments on commit 91fbbca

Please sign in to comment.