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

dml on table contains generated columns report assertion failed error #53967

Closed
aytrack opened this issue Jun 12, 2024 · 1 comment · Fixed by #55829
Closed

dml on table contains generated columns report assertion failed error #53967

aytrack opened this issue Jun 12, 2024 · 1 comment · Fixed by #55829
Labels
affects-6.5 affects-7.1 affects-7.5 affects-8.1 component/ddl This issue is related to DDL of TiDB. report/community The community has encountered this bug. severity/major type/bug The issue is confirmed as a bug.

Comments

@aytrack
Copy link
Contributor

aytrack commented Jun 12, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

 drop table if exists test1;
CREATE TABLE test1 (
col1 bigint(20) NOT NULL ,
col2 varchar(36) NOT NULL ,
col3 int(11) DEFAULT NULL ,
col4 varchar(36) NOT NULL ,
col5 varchar(255) DEFAULT NULL ,
modify_time bigint(20) DEFAULT NULL,
create_time bigint(20) DEFAULT NULL,
col6 json DEFAULT NULL ,
col7 json DEFAULT NULL ,
col8 json GENERATED ALWAYS AS (json_merge_patch(ifnull(col6, _utf8mb4"{}"), ifnull(col7, _utf8mb4"{}"))) STORED,
col9 varchar(36) GENERATED ALWAYS AS (left(json_unquote(json_extract(col8, _utf8mb4"$.col9[0]")), 36)) VIRTUAL,
col10 varchar(30) GENERATED ALWAYS AS (left(json_unquote(json_extract(col8, _utf8mb4"$.col10")), 30)) VIRTUAL,
KEY dev_idx1 (col4,col1,col10,col3,col5),
KEY dev_idx2 (col3,col1,col9)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

INSERT INTO test1 VALUES (-100000000, "123459789332", 1, "123459789332", "AAAAA", 1675871871, 1675760995, '{"col10": "CCCCC", "col9": ["ABCDEFG"]}', '{"col10": "DDDDD", "col9": ["abcdefg"]}', DEFAULT, DEFAULT, DEFAULT);
INSERT INTO test1 VALUES (-100000000, "123459789332", 1, "123459789332", "BBBBB", 1675908861, 1675908861, '{"col10": "CCCCC", "col9": ["ABCDEFG"]}', NULL, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO test1 VALUES (0, "123459789332", 1, "123459789332", "AAAAA", 1675956409, 1675908882, '{"col10": "CCCCC", "col9": ["ABCDEFG"]}', '{"col10": "DDDDD","col9": ["abcdefg"]}', DEFAULT, DEFAULT, DEFAULT);
INSERT INTO test1 VALUES (-100000000, "123459789332", 1, "123459789332", "BBBBB", 1675871896, 1675871896, '{"col10": "CCCCC","col9": ["ABCDEFG"]}', NULL, DEFAULT, DEFAULT, DEFAULT);
INSERT INTO test1 VALUES (-100000000, "123459789332", 1, "123459789332", "AAAAA", 1675908836, 1675871916, '{"col10": "CCCCC","col9": ["ABCDEFG"]}', '{"col10": "DDDDD","col9": ["abcdefg"]}', DEFAULT, DEFAULT, DEFAULT);
UPDATE test1 SET col7 = '{"col10":"DDDDD","col9":["abcdefg"]}' WHERE col2 = "123459789332";
UPDATE test1 SET col1 = -100000000 WHERE col4 = "123459789332";
DELETE FROM test1 WHERE col1 < 0;

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

execute delete sql success

3. What did you see instead (Required)

[18:00:03]TiDB root:test> DELETE FROM test1 WHERE col1 < 0;
(8141, 'assertion failed: key: 74800000000000006e5f698000000000000001013132333435393738ff3933333200000000fb037ffffffffa0a1f00014444444444000000fc038000000000000001014242424242000000fc038000000000000002, assertion: Exist, start_ts: 450412256536559619, existing start ts: 0, existing commit ts: 0')

4. What is your TiDB version? (Required)

[18:00:16]TiDB root:test> select tidb_version();
+-----------------------------------------------------------+
| tidb_version()                                            |
+-----------------------------------------------------------+
| Release Version: v8.2.0-alpha-170-g9da001d777             |
| Edition: Community                                        |
| Git Commit Hash: 9da001d7772363a4ae836999150d5af75b2022ee |
| Git Branch: HEAD                                          |
| UTC Build Time: 2024-05-16 03:50:13                       |
| GoVersion: go1.21.6                                       |
| Race Enabled: false                                       |
| Check Table Before Drop: false                            |
| Store: tikv                                               |
+-----------------------------------------------------------+
1 row in set
@aytrack aytrack added the type/bug The issue is confirmed as a bug. label Jun 12, 2024
@jebter jebter added the sig/transaction SIG:Transaction label Jun 14, 2024
@aytrack aytrack added the report/community The community has encountered this bug. label Jun 20, 2024
@ti-chi-bot ti-chi-bot bot added may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Jul 11, 2024
@cfzjywxk
Copy link
Contributor

The key is generated incorrectly so the assertion check fails, @wjhuang2016 @tangenta PTAL

@cfzjywxk cfzjywxk added the component/ddl This issue is related to DDL of TiDB. label Aug 26, 2024
@jebter jebter removed the sig/transaction SIG:Transaction label Aug 26, 2024
@wjhuang2016 wjhuang2016 removed may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Sep 3, 2024
@ti-chi-bot ti-chi-bot bot closed this as completed in b91cb01 Sep 4, 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.5 affects-8.1 component/ddl This issue is related to DDL of TiDB. report/community The community has encountered this bug. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants