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

exchange partition will fail when table has placement policy and then insert will fail forever #45791

Closed
lcwangchao opened this issue Aug 3, 2023 · 2 comments · Fixed by #45877 or #46126
Assignees
Labels
affects-6.5 affects-7.1 affects-7.2 affects-7.3 report/community The community has encountered this bug. severity/major sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@lcwangchao
Copy link
Collaborator

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE PLACEMENT POLICY rule1 FOLLOWERS=4;
CREATE TABLE `t1` (
  `date` date NOT NULL ,
  `name` varchar(10)  NOT NULL,
  UNIQUE KEY `uk_1` (`date`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin PLACEMENT POLICY=`rule1`;


CREATE TABLE `t1_partition` (
  `date` date NOT NULL ,
  `name` varchar(10)  NOT NULL,
  UNIQUE KEY `uk_1` (`date`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin  PLACEMENT POLICY=`rule1`
PARTITION BY RANGE COLUMNS(`date`)
(PARTITION `p202307` VALUES LESS THAN ('2023-08-01'),
 PARTITION `p202308` VALUES LESS THAN ('2023-09-01'),
 PARTITION `p202309` VALUES LESS THAN ('2023-10-01'),
 PARTITION `p202310` VALUES LESS THAN ('2023-11-01'),
 PARTITION `p202311` VALUES LESS THAN ('2023-12-01'),
 PARTITION `p202312` VALUES LESS THAN ('2024-01-01'),
 PARTITION `pfuture` VALUES LESS THAN (MAXVALUE));

alter table t1_partition exchange partition p202307 with table t1; -- this query will fail
insert into t1(date, name) values ("2023-08-06","0000"); -- then this insert will fail too

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

no error

3. What did you see instead (Required)

TiDB root@127.0.0.1:test> alter table t1_partition exchange partition p202307 with table t1;
(1736, 'Tables have different definitions')

TiDB root@127.0.0.1:test> insert into t1(date, name) values ("2023-08-06","0000");
(1748, 'Found a row not matching the given partition set')

4. What is your TiDB version? (Required)

master, but I think it affects TiDB after v5.4.0

@lcwangchao lcwangchao added type/bug The issue is confirmed as a bug. severity/major labels Aug 3, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.2 This bug maybe affects 5.2.x versions. 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 Aug 3, 2023
@lcwangchao
Copy link
Collaborator Author

It may be introduced by this PR: #35749

  1. It will check whether the partition and table's placement settings match. However, the case that partition's placement settings are inherited from the parent table is not considered.
  2. When the placement check fails, the DDL job will also fail. But the intermediate meta is not rollbacked and an error: "Found a row not matching the given partition set" will be returned when doing insert because the meta is corrupted

@lcwangchao lcwangchao added the sig/sql-infra SIG: SQL Infra label Aug 3, 2023
@mjonss mjonss self-assigned this Aug 3, 2023
ti-chi-bot bot pushed a commit that referenced this issue Aug 10, 2023
ti-chi-bot bot pushed a commit that referenced this issue Aug 17, 2023
mjonss added a commit to ti-chi-bot/tidb that referenced this issue Aug 17, 2023
ti-chi-bot bot pushed a commit that referenced this issue Sep 11, 2023
YangKeao pushed a commit to YangKeao/tidb that referenced this issue Sep 12, 2023
close pingcap#45791, close pingcap#45920

Signed-off-by: Yang Keao <yangkeao@chunibyo.icu>
ti-chi-bot bot pushed a commit that referenced this issue Sep 16, 2023
@lijie0123 lijie0123 mentioned this issue Sep 21, 2023
11 tasks
ti-chi-bot bot pushed a commit that referenced this issue Oct 10, 2023
@seiya-annie
Copy link

/found community

@ti-chi-bot ti-chi-bot bot added the report/community The community has encountered this bug. label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.5 affects-7.1 affects-7.2 affects-7.3 report/community The community has encountered this bug. 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