tidb
tidb copied to clipboard
executor: ALTER TABLE COMPACT support partition
Signed-off-by: hehechen [email protected]
What problem does this PR solve?
Issue Number: close https://github.com/pingcap/tidb/issues/36175 ref https://github.com/pingcap/tiflash/issues/5315
Problem Summary:
In https://github.com/pingcap/tidb/pull/34741 and https://github.com/pingcap/tidb/pull/36368, ALTER TABLE [name] COMPACT and ALTER TABLE [name] COMPACT TIFLASH REPLICA syntax has been added. Deal with partition tables, allowing more fine-grained control. The syntax can be extended as: ALTER TABLE [name] PARTITION [PartitionNameList] COMPACT and ALTER TABLE [name] PARTITION [PartitionNameList] COMPACT TIFLASH REPLICA
What is changed and how it works?
-
Parser: Add new syntaxes: ALTER TABLE [name] PARTITION [PartitionNameList] COMPACT ALTER TABLE [name] PARTITION [PartitionNameList] COMPACT TIFLASH REPLICA.
-
Executor: In compact_table executor, find the partition name in table info, and send compact request to TiFlash for these partitions.
Check List
Tests
- [x] Unit test
- [ ] Integration test
- [x] Manual test (add detailed scripts or steps below)
- [x] compact partition table, with valid and invalid partition name list.
- [x] Use
PARTITIONand noPARTITIONto compact a table without partition respectively.
- [ ] No code
Side effects
- [ ] Performance regression: Consumes more CPU
- [ ] Performance regression: Consumes more Memory
- [ ] Breaking backward compatibility
Documentation
- [ ] Affects user behaviors
- [ ] Contains syntax changes
- [ ] Contains variable changes
- [ ] Contains experimental features
- [ ] Changes MySQL compatibility
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
None
[REVIEW NOTIFICATION]
This pull request has been approved by:
- breezewish
- crazycs520
To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.
The full list of commands accepted by this bot can be found here.
Reviewer can indicate their review by submitting an approval review. Reviewer can cancel approval by submitting a request changes review.
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/abbb12aa94ffe857441cba93b9f00c2aed94bf80
/rebuild
/cc @breezewish
/cc @windtalker
/cc @windtalker
I'm not sure if alter table t compact partition p1,p2,... tiflash replica is a good statement, my first thought was alter table t partition(p1,p2,...) compact tiflash replica, because MySQL has a similar statement that you can select data from some partitions.
https://dev.mysql.com/doc/refman/8.0/en/partitioning-selection.html
I'm not sure if
alter table t compact partition p1,p2,... tiflash replicais a good statement, my first thought wasalter table t partition(p1,p2,...) compact tiflash replica, because MySQL has a similar statement that you can select data from some partitions. https://dev.mysql.com/doc/refman/8.0/en/partitioning-selection.html
https://dev.mysql.com/doc/refman/8.0/en/partitioning-maintenance.html
MySQL has similar statements ALTER TABLE t1 OPTIMIZE PARTITION p0, p1; and ALTER TABLE t1 ANALYZE PARTITION p3;.
/merge
This pull request has been accepted and is ready to merge.
TiDB MergeCI notify
🔴 Bad News! [1] CI still failing after this pr merged. These failed integration tests don't seem to be introduced by the current PR.
| CI Name | Result | Duration | Compare with Parent commit |
|---|---|---|---|
| idc-jenkins-ci-tidb/common-test | 🔴 failed 1, success 10, total 11 | 8 min 34 sec | Existing failure |
| idc-jenkins-ci/integration-cdc-test | 🟢 all 37 tests passed | 26 min | Existing passed |
| idc-jenkins-ci-tidb/integration-ddl-test | 🟢 all 6 tests passed | 24 min | Existing passed |
| idc-jenkins-ci-tidb/integration-common-test | 🟢 all 17 tests passed | 11 min | Existing passed |
| idc-jenkins-ci-tidb/tics-test | 🟢 all 1 tests passed | 6 min 21 sec | Existing passed |
| idc-jenkins-ci-tidb/sqllogic-test-2 | 🟢 all 28 tests passed | 5 min 50 sec | Existing passed |
| idc-jenkins-ci-tidb/sqllogic-test-1 | 🟢 all 26 tests passed | 5 min 39 sec | Existing passed |
| idc-jenkins-ci-tidb/mybatis-test | 🟢 all 1 tests passed | 3 min 1 sec | Existing passed |
| idc-jenkins-ci-tidb/integration-compatibility-test | 🟢 all 1 tests passed | 2 min 49 sec | Existing passed |
| idc-jenkins-ci-tidb/plugin-test | 🟢 build success, plugin test success | 4min | Existing passed |