Skip to content

Commit

Permalink
schemachanger: add support for discarding subzones
Browse files Browse the repository at this point in the history
This patch adds support for discarding a subzone config in the
DSC.

Fixes: #133158
Epic: none

Release note: None
  • Loading branch information
annrpom committed Nov 23, 2024
1 parent 09eedc5 commit bd1cf6d
Show file tree
Hide file tree
Showing 60 changed files with 1,209 additions and 139 deletions.
28 changes: 28 additions & 0 deletions pkg/ccl/schemachangerccl/backup_base_generated_test.go

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

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.

3 changes: 3 additions & 0 deletions pkg/ccl/schemachangerccl/testdata/decomp/multiregion
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@ ElementState:
Status: PUBLIC
- PartitionZoneConfig:
indexId: 1
oldIdxRef: -1
partitionName: us-east1
seqNum: 0
subzone:
Expand Down Expand Up @@ -1392,6 +1393,7 @@ ElementState:
Status: PUBLIC
- PartitionZoneConfig:
indexId: 1
oldIdxRef: -1
partitionName: us-east2
seqNum: 0
subzone:
Expand Down Expand Up @@ -1429,6 +1431,7 @@ ElementState:
Status: PUBLIC
- PartitionZoneConfig:
indexId: 1
oldIdxRef: -1
partitionName: us-east3
seqNum: 0
subzone:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── 1 element transitioning toward PUBLIC
│ │ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 1}
│ └── 1 Mutation operation
│ └── AddIndexZoneConfig {"TableID":104}
│ └── AddIndexZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
└── PreCommitPhase
├── Stage 1 of 2 in PreCommitPhase
│ ├── 1 element transitioning toward PUBLIC
Expand All @@ -22,4 +22,4 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
├── 1 element transitioning toward PUBLIC
│ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 1}
└── 1 Mutation operation
└── AddIndexZoneConfig {"TableID":104}
└── AddIndexZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── 1 element transitioning toward PUBLIC
│ │ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 1}
│ └── 1 Mutation operation
│ └── AddIndexZoneConfig {"TableID":104}
│ └── AddIndexZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
└── PreCommitPhase
├── Stage 1 of 2 in PreCommitPhase
│ ├── 1 element transitioning toward PUBLIC
Expand All @@ -22,4 +22,4 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
├── 1 element transitioning toward PUBLIC
│ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 1}
└── 1 Mutation operation
└── AddIndexZoneConfig {"TableID":104}
└── AddIndexZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── 1 element transitioning toward PUBLIC
│ │ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 2}
│ └── 1 Mutation operation
│ └── AddIndexZoneConfig {"TableID":104}
│ └── AddIndexZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
└── PreCommitPhase
├── Stage 1 of 2 in PreCommitPhase
│ ├── 2 elements transitioning toward PUBLIC
Expand All @@ -25,5 +25,5 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 1}
│ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 2}
└── 2 Mutation operations
├── AddIndexZoneConfig {"TableID":104}
└── AddIndexZoneConfig {"TableID":104}
├── AddIndexZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
└── AddIndexZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── 1 element transitioning toward PUBLIC
│ │ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 3}
│ └── 1 Mutation operation
│ └── AddIndexZoneConfig {"TableID":104}
│ └── AddIndexZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
└── PreCommitPhase
├── Stage 1 of 2 in PreCommitPhase
│ ├── 3 elements transitioning toward PUBLIC
Expand All @@ -28,6 +28,6 @@ Schema change plan for ALTER INDEX ‹defaultdb›.‹public›.‹t›@‹foo
│ ├── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 2}
│ └── ABSENT → PUBLIC IndexZoneConfig:{DescID: 104 (t), IndexID: 2 (foo), SeqNum: 3}
└── 3 Mutation operations
├── AddIndexZoneConfig {"TableID":104}
├── AddIndexZoneConfig {"TableID":104}
└── AddIndexZoneConfig {"TableID":104}
├── AddIndexZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
├── AddIndexZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
└── AddIndexZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Schema change plan for ALTER PARTITION ‹p1› OF INDEX ‹defaultdb›.‹publ
│ ├── 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}
│ └── AddPartitionZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
└── PreCommitPhase
├── Stage 1 of 2 in PreCommitPhase
│ ├── 1 element transitioning toward PUBLIC
Expand All @@ -27,4 +27,4 @@ Schema change plan for ALTER PARTITION ‹p1› OF INDEX ‹defaultdb›.‹publ
├── 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}
└── AddPartitionZoneConfig {"SubzoneIndexToDelete":-1,"TableID":104}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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 = 11;
ALTER PARTITION p1 OF INDEX t@t_pkey CONFIGURE ZONE USING num_replicas = 12;
ALTER PARTITION p2 OF INDEX t@t_pkey CONFIGURE ZONE USING num_replicas = 10;
ALTER PARTITION p1 OF INDEX t@t_pkey CONFIGURE ZONE DISCARD;
----
Loading

0 comments on commit bd1cf6d

Please sign in to comment.