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

explain analyze causes wrong result when txn is too large #35105

Closed
you06 opened this issue Jun 1, 2022 · 1 comment · Fixed by #36105
Closed

explain analyze causes wrong result when txn is too large #35105

you06 opened this issue Jun 1, 2022 · 1 comment · Fixed by #36105
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 severity/major sig/sql-infra SIG: SQL Infra sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.

Comments

@you06
Copy link
Contributor

you06 commented Jun 1, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Run TiDB and load data with sysbench.

sysbench --config-file=config oltp_point_select --tables=1 --table-size=500000 prepare

Create table with same schema and load data by explain analyze insert select

create table sbtest2(id int(11) NOT NULL AUTO_INCREMENT, `k` int(11) NOT NULL DEFAULT '0',`c` char(120) NOT NULL DEFAULT '',`pad` char(60) NOT NULL DEFAULT '',PRIMARY KEY (`id`),KEY `k_1` (`k`));
explain analyze insert into sbtest2 select * from sbtest1;

P.S. if we just run insert select without explain analyze, it'll return txn-too-large error.

MySQL [test]> insert into sbtest2 select * from sbtest1;
ERROR 8004 (HY000): Transaction is too large, size: 104857766

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

If the statement execution succeeds, the data in sbtest2 should be the same as sbtest1.

MySQL [test]> select count(1) from sbtest2;
+----------+
| count(1) |
+----------+
|   500000 |
+----------+
1 row in set (2.857 sec)

MySQL [test]> select count(1) from sbtest1;
+----------+
| count(1) |
+----------+
|   500000 |
+----------+
1 row in set (0.242 sec)

3. What did you see instead (Required)

The data in sbtest2 is truncated.

MySQL [test]> select count(1) from sbtest2;
+----------+
| count(1) |
+----------+
|   412825 |
+----------+
1 row in set (2.857 sec)

MySQL [test]> select count(1) from sbtest1;
+----------+
| count(1) |
+----------+
|   500000 |
+----------+
1 row in set (0.242 sec)

The transaction details in TiDB dashboard are missing.

image

4. What is your TiDB version? (Required)

Release Version: v6.2.0-alpha
Edition: Community
Git Commit Hash: e2fd394fbfaf1ace2bb129c0e7863bd20f087152
Git Branch: heads/refs/tags/v6.2.0-alpha
UTC Build Time: 2022-05-31 14:58:00
GoVersion: go1.18.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
Store: tikv
@you06 you06 added the type/bug The issue is confirmed as a bug. label Jun 1, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. 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.0 may-affects-6.1 labels Jun 2, 2022
@seiya-annie seiya-annie added sig/transaction SIG:Transaction affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 and removed may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. 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-5.0 This bug maybe affects 5.0.x versions. may-affects-6.0 may-affects-6.1 labels Jun 2, 2022
@zyguan
Copy link
Contributor

zyguan commented Jul 11, 2022

A minimal reproducible case:

/* t */ drop table if exists t;
/* t */ create table t (a int primary key);
/* t */ insert into t values (2);
/* t */ set @@tidb_constraint_check_in_place=1;
/* t */ explain analyze insert into t values (1), (2), (3); -- ok
/* t */ select * from t; -- [1, 2]

@zyguan zyguan added the sig/execution SIG execution label Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 severity/major sig/sql-infra SIG: SQL Infra sig/transaction SIG:Transaction type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants