Skip to content

Commit

Permalink
schemachanger: refactor subzone config elements
Browse files Browse the repository at this point in the history
TODO
  • Loading branch information
annrpom committed Nov 4, 2024
1 parent 8566eaf commit b2f189e
Show file tree
Hide file tree
Showing 29 changed files with 823 additions and 113 deletions.
70 changes: 70 additions & 0 deletions pkg/ccl/schemachangerccl/ccl_generated_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 24 additions & 6 deletions pkg/ccl/schemachangerccl/testdata/decomp/multiregion
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,10 @@ ElementState:
numReplicas: 2
indexId: 1
partitionName: us-east1
subzoneSpans: []
subzoneSpans:
- endKey: null
key: iRJAAAE=
subzoneIndex: 0
tableId: 108
Status: PUBLIC
- IndexZoneConfig:
Expand Down Expand Up @@ -1406,7 +1409,10 @@ ElementState:
numReplicas: 2
indexId: 1
partitionName: us-east2
subzoneSpans: []
subzoneSpans:
- endKey: null
key: iRKAAAE=
subzoneIndex: 1
tableId: 108
Status: PUBLIC
- IndexZoneConfig:
Expand Down Expand Up @@ -1439,7 +1445,10 @@ ElementState:
numReplicas: 2
indexId: 1
partitionName: us-east3
subzoneSpans: []
subzoneSpans:
- endKey: null
key: iRLAAAE=
subzoneIndex: 2
tableId: 108
Status: PUBLIC
- Namespace:
Expand Down Expand Up @@ -1483,7 +1492,10 @@ ElementState:
numReplicas: 2
indexId: 1
partitionName: us-east1
subzoneSpans: []
subzoneSpans:
- endKey: null
key: iRJAAAE=
subzoneIndex: 0
tableId: 108
Status: PUBLIC
- PartitionZoneConfig:
Expand Down Expand Up @@ -1517,7 +1529,10 @@ ElementState:
numReplicas: 2
indexId: 1
partitionName: us-east2
subzoneSpans: []
subzoneSpans:
- endKey: null
key: iRKAAAE=
subzoneIndex: 1
tableId: 108
Status: PUBLIC
- PartitionZoneConfig:
Expand Down Expand Up @@ -1551,7 +1566,10 @@ ElementState:
numReplicas: 2
indexId: 1
partitionName: us-east3
subzoneSpans: []
subzoneSpans:
- endKey: null
key: iRLAAAE=
subzoneIndex: 2
tableId: 108
Status: PUBLIC
- PrimaryIndex:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
setup
CREATE TABLE person (
name STRING,
country STRING,
birth_date DATE,
PRIMARY KEY (country, birth_date, name)
)
PARTITION BY LIST (country) (
PARTITION australia
VALUES IN ('AU', 'NZ')
PARTITION BY RANGE (birth_date)
(
PARTITION old_au VALUES FROM (minvalue) TO ('1995-01-01'),
PARTITION yung_au VALUES FROM ('1995-01-01') TO (maxvalue)
),
PARTITION north_america
VALUES IN ('US', 'CA')
PARTITION BY RANGE (birth_date)
(
PARTITION old_na VALUES FROM (minvalue) TO ('1995-01-01'),
PARTITION yung_na VALUES FROM ('1995-01-01') TO (maxvalue)
),
PARTITION default
VALUES IN (default)
);
----

test
ALTER PARTITION australia OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 2;
ALTER PARTITION old_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 4;
ALTER PARTITION yung_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 5;
ALTER PARTITION old_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 6;
----
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/* setup */
CREATE TABLE person (
name STRING,
country STRING,
birth_date DATE,
PRIMARY KEY (country, birth_date, name)
)
PARTITION BY LIST (country) (
PARTITION australia
VALUES IN ('AU', 'NZ')
PARTITION BY RANGE (birth_date)
(
PARTITION old_au VALUES FROM (minvalue) TO ('1995-01-01'),
PARTITION yung_au VALUES FROM ('1995-01-01') TO (maxvalue)
),
PARTITION north_america
VALUES IN ('US', 'CA')
PARTITION BY RANGE (birth_date)
(
PARTITION old_na VALUES FROM (minvalue) TO ('1995-01-01'),
PARTITION yung_na VALUES FROM ('1995-01-01') TO (maxvalue)
),
PARTITION default
VALUES IN (default)
);
----
...
+object {100 101 person} -> 104

/* test */
ALTER PARTITION australia OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 2;
ALTER PARTITION old_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 4;
ALTER PARTITION yung_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 5;
ALTER PARTITION old_au OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 6;
----
begin transaction #1
# begin StatementPhase
checking for feature: CONFIGURE ZONE
write *eventpb.SetZoneConfig to event log:
config:
options:
- '"gc.ttlseconds" = 2'
target: PARTITION australia OF INDEX defaultdb.public.person@person_pkey
resolvedOldConfig: 'inherited_constraints:false null_voter_constraints_is_empty:false inherited_lease_preferences:false '
sql:
descriptorId: 104
statement: ALTER PARTITION ‹australia› OF INDEX ‹defaultdb›.‹public›.‹person›@‹person_pkey› CONFIGURE ZONE USING ‹"gc.ttlseconds"› = ‹2›
tag: CONFIGURE ZONE
user: root
## StatementPhase stage 1 of 1 with 1 MutationType op
upsert zone config for #104
checking for feature: CONFIGURE ZONE
write *eventpb.SetZoneConfig to event log:
config:
options:
- '"gc.ttlseconds" = 4'
target: PARTITION old_au OF INDEX defaultdb.public.person@person_pkey
resolvedOldConfig: 'inherited_constraints:false null_voter_constraints_is_empty:false inherited_lease_preferences:false '
sql:
descriptorId: 104
statement: ALTER PARTITION ‹old_au› OF INDEX ‹defaultdb›.‹public›.‹person›@‹person_pkey› CONFIGURE ZONE USING ‹"gc.ttlseconds"› = ‹4›
tag: CONFIGURE ZONE
user: root
## StatementPhase stage 1 of 1 with 1 MutationType op
upsert zone config for #104
checking for feature: CONFIGURE ZONE
write *eventpb.SetZoneConfig to event log:
config:
options:
- '"gc.ttlseconds" = 5'
target: PARTITION yung_au OF INDEX defaultdb.public.person@person_pkey
resolvedOldConfig: 'inherited_constraints:false null_voter_constraints_is_empty:false inherited_lease_preferences:false '
sql:
descriptorId: 104
statement: ALTER PARTITION ‹yung_au› OF INDEX ‹defaultdb›.‹public›.‹person›@‹person_pkey› CONFIGURE ZONE USING ‹"gc.ttlseconds"› = ‹5›
tag: CONFIGURE ZONE
user: root
## StatementPhase stage 1 of 1 with 1 MutationType op
upsert zone config for #104
checking for feature: CONFIGURE ZONE
write *eventpb.SetZoneConfig to event log:
config:
options:
- '"gc.ttlseconds" = 6'
target: PARTITION old_au OF INDEX defaultdb.public.person@person_pkey
resolvedOldConfig: 'inherited_constraints:false null_voter_constraints_is_empty:false inherited_lease_preferences:false '
sql:
descriptorId: 104
statement: ALTER PARTITION ‹old_au› OF INDEX ‹defaultdb›.‹public›.‹person›@‹person_pkey› CONFIGURE ZONE USING ‹"gc.ttlseconds"› = ‹6›
tag: CONFIGURE ZONE
user: root
## StatementPhase stage 1 of 1 with 1 MutationType op
upsert zone config for #104
# end StatementPhase
# begin PreCommitPhase
## PreCommitPhase stage 1 of 2 with 1 MutationType op
undo all catalog changes within txn #1
persist all catalog changes to storage
## PreCommitPhase stage 2 of 2 with 4 MutationType ops
upsert zone config for #104
persist all catalog changes to storage
# end PreCommitPhase
commit transaction #1
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* setup */
CREATE TABLE person (
name STRING,
country STRING,
birth_date DATE,
PRIMARY KEY (country, birth_date, name)
)
PARTITION BY LIST (country) (
PARTITION australia
VALUES IN ('AU', 'NZ')
PARTITION BY RANGE (birth_date)
(
PARTITION old_au VALUES FROM (minvalue) TO ('1995-01-01'),
PARTITION yung_au VALUES FROM ('1995-01-01') TO (maxvalue)
),
PARTITION north_america
VALUES IN ('US', 'CA')
PARTITION BY RANGE (birth_date)
(
PARTITION old_na VALUES FROM (minvalue) TO ('1995-01-01'),
PARTITION yung_na VALUES FROM ('1995-01-01') TO (maxvalue)
),
PARTITION default
VALUES IN (default)
);

/* test */
EXPLAIN (DDL) ALTER PARTITION australia OF TABLE person CONFIGURE ZONE USING gc.ttlseconds = 2;
----
Schema change plan for ALTER PARTITION ‹australia› OF INDEX ‹defaultdb›.‹public›.‹person›@‹person_pkey› CONFIGURE ZONE USING ‹"gc.ttlseconds"› = ‹2›;
├── StatementPhase
│ └── Stage 1 of 1 in StatementPhase
│ ├── 1 element transitioning toward PUBLIC
│ │ └── ABSENT → PUBLIC PartitionZoneConfig:{DescID: 104 (person), IndexID: 1 (person_pkey), SeqNum: 1, PartitionName: "australia"}
│ └── 1 Mutation operation
│ └── AddPartitionZoneConfig {"TableID":104}
└── PreCommitPhase
├── Stage 1 of 2 in PreCommitPhase
│ ├── 1 element transitioning toward PUBLIC
│ │ └── PUBLIC → ABSENT PartitionZoneConfig:{DescID: 104 (person), IndexID: 1 (person_pkey), SeqNum: 1, PartitionName: "australia"}
│ └── 1 Mutation operation
│ └── UndoAllInTxnImmediateMutationOpSideEffects
└── Stage 2 of 2 in PreCommitPhase
├── 1 element transitioning toward PUBLIC
│ └── ABSENT → PUBLIC PartitionZoneConfig:{DescID: 104 (person), IndexID: 1 (person_pkey), SeqNum: 1, PartitionName: "australia"}
└── 1 Mutation operation
└── AddPartitionZoneConfig {"TableID":104}
Loading

0 comments on commit b2f189e

Please sign in to comment.