Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALTER TABLE t PARTITION BY gives error when specifying PLACEMENT POLICY #48630

Closed
mjonss opened this issue Nov 15, 2023 · 1 comment · Fixed by #48631
Closed

ALTER TABLE t PARTITION BY gives error when specifying PLACEMENT POLICY #48630

mjonss opened this issue Nov 15, 2023 · 1 comment · Fixed by #48631
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@mjonss
Copy link
Contributor

mjonss commented Nov 15, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create placement policy pp1 followers=1;
create table t (a int);
alter table t partition by range (a) (partition p0 values less than (1000000), partition pMax values less than (maxvalue) placement policy pp1);

2. What did you expect to see? (Required)

tidb> create placement policy pp1 followers=1;
Query OK, 0 rows affected (0.09 sec)

tidb> create table t (a int);
Query OK, 0 rows affected (0.09 sec)

tidb> alter table t partition by range (a) (partition p0 values less than (1000000), partition pMax values less than (maxvalue) placement policy pp1);
Query OK, 0 rows affected, 1 warning (0.05 sec)

3. What did you see instead (Required)

tidb> create placement policy pp1 followers=1;
Query OK, 0 rows affected (0.09 sec)

tidb> create table t (a int);
Query OK, 0 rows affected (0.09 sec)

tidb> alter table t partition by range (a) (partition p0 values less than (1000000), partition pMax values less than (maxvalue) placement policy pp1);
ERROR 8239 (HY000): Unknown placement policy '(Policy ID 0)'

4. What is your TiDB version? (Required)

tidb_version(): Release Version: v7.6.0-alpha
Edition: Community
Git Commit Hash: 625dc4e3cd5d7ebaba592e6a3b8a5697cb28194a
Git Branch: heads/refs/tags/v7.6.0-alpha
UTC Build Time: 2023-11-14 14:26:02
GoVersion: go1.21.3
Race Enabled: false
Check Table Before Drop: false
Store: tikv
@mjonss mjonss added the type/bug The issue is confirmed as a bug. label Nov 15, 2023
@mjonss
Copy link
Contributor Author

mjonss commented Nov 15, 2023

Issue is that the mapping from Placement Policy name to ID is not done, fixed by:

diff --git a/pkg/ddl/ddl_api.go b/pkg/ddl/ddl_api.go
index 2c04151962..82eec78c04 100644
--- a/pkg/ddl/ddl_api.go
+++ b/pkg/ddl/ddl_api.go
@@ -4376,6 +4376,10 @@ func (d *ddl) AlterTablePartitioning(ctx sessionctx.Context, ident ast.Ident, sp
        }
        newPartInfo := newMeta.Partition
 
+       if err = handlePartitionPlacement(ctx, newPartInfo); err != nil {
+               return errors.Trace(err)
+       }
+
        if err = d.assignPartitionIDs(newPartInfo.Definitions); err != nil {
                return errors.Trace(err)
        }

@dveeden dveeden added the component/tablepartition This issue is related to Table Partition of TiDB. label Nov 16, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 labels Nov 17, 2023
@mjonss mjonss added affects-7.5 This bug affects the 7.5.x(LTS) versions. and removed may-affects-7.5 may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 labels Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 This bug affects the 7.5.x(LTS) versions. component/tablepartition This issue is related to Table Partition of TiDB. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants