-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
assertion failed when inserting some rows #50043
Comments
/type regression |
Hi @jebter I think it is a transaction related bug, maybe we should label it as sig/transaction? |
It's possbile a regression related to the codec or execution processing, but not transaction protocol. |
The test case can simplify to: create table t ( c1 boolean ,c2 decimal ( 37 , 17 ), unique key idx1 (c1 ,c2) );
alter table t alter column c2 drop default;
alter table t add unique key idx4 ( c1 );
INSERT INTO t VALUES (0,NULL), (1,1);
insert ignore into t values ( 0,2) ,( 1,3) on duplicate key update c2 = 5, c1 = 0; (8141, 'assertion failed: key: 7480000000000001525f6980000000000000010380000000000000000625118000000000000000000000000000000000, assertion: Exist, start_ts: 447963869755211782, existing start ts: 0, existing commit ts: 0') Decode the key, you can see c2 value is 0.00000000000000000, this is strange, since we never insert 0 value into column c2. select tidb_decode_key( '7480000000000001525f6980000000000000010380000000000000000625118000000000000000000000000000000000' );
+-----------------------------------------------------------------------------------------------------------------------+
| tidb_decode_key( '7480000000000001525f6980000000000000010380000000000000000625118000000000000000000000000000000000' ) |
+-----------------------------------------------------------------------------------------------------------------------+
| {"index_id":1,"index_vals":{"c1":"0","c2":"0.00000000000000000"},"table_id":338} |
+-----------------------------------------------------------------------------------------------------------------------+
AnalyzeThe last SQL statement [tidb/pkg/executor/insert.go at 6e10826f164eb13f6f86640e856b945539b57b0d · pingcap/tidb (github.com)]( Line 80 in 6e10826
But in this issue, actually is So if you remove > insert into t values ( 0,2) ,( 1,3) on duplicate key update c2 = 5, c1 = 0;
(1364, "Field 'c2' doesn't have a default value") This error is unexpected and wired, should fix this issue first. @wjhuang2016 @lcwangchao PTAL Returning to this issue, the reason for this is as follows:
Thanks to the assertion feature, if we disable assertion, this issue will cause a data inconsistency issue: mysql> set @@tidb_txn_assertion_level=off;
Query OK, 0 rows affected (0.00 sec)
mysql> create table t ( c1 boolean ,c2 decimal ( 37 , 17 ), unique key idx1 (c1 ,c2) );
Query OK, 0 rows affected (0.01 sec)
mysql> alter table t alter column c2 drop default;
Query OK, 0 rows affected (0.01 sec)
mysql> alter table t add unique key idx4 ( c1 );
Query OK, 0 rows affected (0.06 sec)
mysql> INSERT INTO t VALUES (0,NULL), (1,1);
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> insert ignore into t values ( 0,2) ,( 1,3) on duplicate key update c2 = 5, c1 = 0;
Query OK, 2 rows affected, 2 warnings (0.00 sec)
Records: 2 Duplicates: 1 Warnings: 2
mysql> admin check table t;
ERROR 8223 (HY000): data inconsistency in table: t, index: idx1, handle: 1, index-values:"handle: 1, values: [KindInt64 0 KindNull <nil>]" != record-values:"handle: 1, values: [KindInt64 0 KindMysqlDecimal 5.00000000000000000]" |
@Defined2014 PTAL |
another simply failed case is: create table t ( c1 boolean ,c2 decimal ( 37 , 17 ), unique key idx1 (c1 ,c2),unique key idx2 ( c1 ));
INSERT INTO t VALUES (0,NULL);
alter table t alter column c2 drop default;
update t set c2=5 where c1=0; (1364, "Field 'c2' doesn't have a default value") |
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
No error
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
33480e8
The text was updated successfully, but these errors were encountered: