forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schemachanger: support partition zone config
This patch adds the functionality to configure a zone configuration on a partition. Fixes: cockroachdb#129889 Release note: None
- Loading branch information
Showing
28 changed files
with
952 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
...tdata/end_to_end/alter_partition_configure_zone/alter_partition_configure_zone.definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
setup | ||
CREATE TABLE t ( | ||
id INT PRIMARY KEY, | ||
data STRING | ||
) PARTITION BY LIST (id) ( | ||
PARTITION p1 VALUES IN (1, 2, 3), | ||
PARTITION p2 VALUES IN (4, 5, 6) | ||
); | ||
---- | ||
|
||
test | ||
ALTER PARTITION p1 OF INDEX t@t_pkey CONFIGURE ZONE USING num_replicas = 7, gc.ttlseconds = 10000; | ||
---- |
30 changes: 30 additions & 0 deletions
30
...testdata/end_to_end/alter_partition_configure_zone/alter_partition_configure_zone.explain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* setup */ | ||
CREATE TABLE t ( | ||
id INT PRIMARY KEY, | ||
data STRING | ||
) PARTITION BY LIST (id) ( | ||
PARTITION p1 VALUES IN (1, 2, 3), | ||
PARTITION p2 VALUES IN (4, 5, 6) | ||
); | ||
|
||
/* test */ | ||
EXPLAIN (DDL) ALTER PARTITION p1 OF INDEX t@t_pkey CONFIGURE ZONE USING num_replicas = 7, gc.ttlseconds = 10000; | ||
---- | ||
Schema change plan for ALTER PARTITION ‹p1› OF INDEX ‹defaultdb›.‹public›.‹t›@‹t_pkey› CONFIGURE ZONE USING ‹num_replicas› = ‹7›, ‹"gc.ttlseconds"› = ‹10000›; | ||
├── StatementPhase | ||
│ └── Stage 1 of 1 in StatementPhase | ||
│ ├── 1 element transitioning toward PUBLIC | ||
│ │ └── ABSENT → PUBLIC PartitionZoneConfig:{DescID: 104 (t), IndexID: 1 (t_pkey), SeqNum: 1, PartitionName: "p1"} | ||
│ └── 1 Mutation operation | ||
│ └── AddPartitionZoneConfig {"TableID":104} | ||
└── PreCommitPhase | ||
├── Stage 1 of 2 in PreCommitPhase | ||
│ ├── 1 element transitioning toward PUBLIC | ||
│ │ └── PUBLIC → ABSENT PartitionZoneConfig:{DescID: 104 (t), IndexID: 1 (t_pkey), SeqNum: 1, PartitionName: "p1"} | ||
│ └── 1 Mutation operation | ||
│ └── UndoAllInTxnImmediateMutationOpSideEffects | ||
└── Stage 2 of 2 in PreCommitPhase | ||
├── 1 element transitioning toward PUBLIC | ||
│ └── ABSENT → PUBLIC PartitionZoneConfig:{DescID: 104 (t), IndexID: 1 (t_pkey), SeqNum: 1, PartitionName: "p1"} | ||
└── 1 Mutation operation | ||
└── AddPartitionZoneConfig {"TableID":104} |
14 changes: 14 additions & 0 deletions
14
...ta/end_to_end/alter_partition_configure_zone/alter_partition_configure_zone.explain_shape
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* setup */ | ||
CREATE TABLE t ( | ||
id INT PRIMARY KEY, | ||
data STRING | ||
) PARTITION BY LIST (id) ( | ||
PARTITION p1 VALUES IN (1, 2, 3), | ||
PARTITION p2 VALUES IN (4, 5, 6) | ||
); | ||
|
||
/* test */ | ||
EXPLAIN (DDL, SHAPE) ALTER PARTITION p1 OF INDEX t@t_pkey CONFIGURE ZONE USING num_replicas = 7, gc.ttlseconds = 10000; | ||
---- | ||
Schema change plan for ALTER PARTITION ‹p1› OF INDEX ‹defaultdb›.‹public›.‹t›@‹t_pkey› CONFIGURE ZONE USING ‹num_replicas› = ‹7›, ‹"gc.ttlseconds"› = ‹10000›; | ||
└── execute 1 system table mutations transaction |
38 changes: 38 additions & 0 deletions
38
...ata/end_to_end/alter_partition_configure_zone/alter_partition_configure_zone.side_effects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* setup */ | ||
CREATE TABLE t ( | ||
id INT PRIMARY KEY, | ||
data STRING | ||
) PARTITION BY LIST (id) ( | ||
PARTITION p1 VALUES IN (1, 2, 3), | ||
PARTITION p2 VALUES IN (4, 5, 6) | ||
); | ||
---- | ||
... | ||
+object {100 101 t} -> 104 | ||
|
||
/* test */ | ||
ALTER PARTITION p1 OF INDEX t@t_pkey CONFIGURE ZONE USING num_replicas = 7, gc.ttlseconds = 10000; | ||
---- | ||
begin transaction #1 | ||
# begin StatementPhase | ||
checking for feature: CONFIGURE ZONE | ||
write *eventpb.AlterTable to event log: | ||
mutationId: 1 | ||
sql: | ||
descriptorId: 104 | ||
statement: ALTER PARTITION ‹p1› OF INDEX ‹defaultdb›.‹public›.‹t›@‹t_pkey› CONFIGURE ZONE USING ‹num_replicas› = ‹7›, ‹"gc.ttlseconds"› = ‹10000› | ||
tag: CONFIGURE ZONE | ||
user: root | ||
tableName: defaultdb.public.t | ||
## 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 1 MutationType op | ||
upsert zone config for #104 | ||
persist all catalog changes to storage | ||
# end PreCommitPhase | ||
commit transaction #1 |
20 changes: 20 additions & 0 deletions
20
...lter_partition_configure_zone_multiple/alter_partition_configure_zone_multiple.definition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
setup | ||
CREATE TABLE t ( | ||
id INT PRIMARY KEY, | ||
data INT, | ||
INDEX idx (data) PARTITION BY LIST (data) ( | ||
PARTITION p1 VALUES IN (10, 20, 30), | ||
PARTITION p2 VALUES IN (40, 50, 60) | ||
) | ||
) PARTITION BY LIST (id) ( | ||
PARTITION p1 VALUES IN (1, 2, 3), | ||
PARTITION p2 VALUES IN (4, 5, 6) | ||
); | ||
---- | ||
|
||
test | ||
ALTER PARTITION p1 OF INDEX t@t_pkey CONFIGURE ZONE USING num_replicas = 7; | ||
ALTER PARTITION p1 OF INDEX t@t_pkey CONFIGURE ZONE USING gc.ttlseconds = 10000; | ||
ALTER PARTITION p1 OF INDEX t@idx CONFIGURE ZONE USING gc.ttlseconds = 12000; | ||
ALTER PARTITION p1 OF INDEX t@t_pkey CONFIGURE ZONE USING num_replicas = 10; | ||
---- |
Oops, something went wrong.