pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.2k stars 5.84k forks source link

commit transaction with create_complexindex_decimal,report "key xxx out of [region xx]" #38193

Closed seiya-annie closed 2 years ago

seiya-annie commented 2 years ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

set global tidb_ddl_enable_fast_reorg=on; set global tidb_ddl_disk_quota=107374182400; run following test cases:

/* init */ drop table if exists t1,t2,t3,t4,t5,t6,t1_test,t2_test,t3_test,t4_test,t5_test,t6_test;
-- init >> 0 rows affected
/* init */ CREATE TABLE t3_test ( id int,f FLOAT, f1 FLOAT(10,2), d DOUBLE, d1 DOUBLE(10,2), dm DECIMAL, dm1 DECIMAL(10,2) ) ;
-- init >> 0 rows affected
/* init */ INSERT INTO t3_test VALUES (10,-3.302823466E+38, -34028234.66, -1.7976931348623157E+308, -17976921.34, -9999999999, -99999999.99);
-- init >> 1 rows affected
/* init */ CREATE TABLE t3 ( id int,f FLOAT, f1 FLOAT(10,2), d DOUBLE, d1 DOUBLE(10,2), dm DECIMAL, dm1 DECIMAL(10,2) ) ;
-- init >> 0 rows affected
/* init */ INSERT INTO t3 VALUES (1,-3.402823466E+38, -34028234.66, -1.7976931348623157E+308, -17976921.34, -9999999999, -99999999.99);
-- init >> 1 rows affected
/* txn:wait */ set tidb_enable_amend_pessimistic_txn=1;
-- txn >> 0 rows affected
/* txn2 */ set tidb_enable_amend_pessimistic_txn=1;
-- txn2 >> 0 rows affected
/* txn:wait */ Begin;
-- txn >> 0 rows affected
/* txn */ select * from t3 where id=1 for update;
-- txn >> +----+-------------+-----------+-------------------------+--------------+-------------+--------------+
-- txn    | ID |      F      |    F1     |            D            |      D1      |     DM      |     DM1      |
-- txn    +----+-------------+-----------+-------------------------+--------------+-------------+--------------+
-- txn    |  1 | -3.40282e38 | -34028236 | -1.7976931348623157e308 | -17976921.34 | -9999999999 | -99999999.99 |
-- txn    +----+-------------+-----------+-------------------------+--------------+-------------+--------------+
/* txn */ INSERT INTO t3 VALUES (2,-2.402823466E+38, -24028234.66, -1.7876931348623157E+308, -17876921.34, -9999999998, -99999998.99);
-- txn >> 1 rows affected
/* txn */ UPDATE t3 SET f = 3.402823466E+38, f1 = 34028234.66, d = 1.7976931348623157E+308, d1 = 17976921.34, dm = 9999999999, dm1 = 99999999.99 WHERE id=1;
-- txn >> 1 rows affected
/* txn */ INSERT INTO t3 select  * from  t3_test  where id = 10;
-- txn >> 1 rows affected
/* txn */ replace  into  t3 VALUES (2,-2.402823466E+38, -24028234.66, -1.7876931348623157E+308, -17876921.34, -9999999998, -99999998.99);
-- txn >> 1 rows affected
/* txn */ insert   into  t3 VALUES (2,-2.402823466E+38, -24028234.66, -1.7876931348623157E+308, -17876921.34, -9999999998, -99999998.99) on duplicate key update dm=dm+10;
-- txn >> 1 rows affected
/* ddl */ Create  index t3_ind_c on t3 (id,dm);
-- ddl >> blocked
/* txn */ Commit;
-- txn >> 0 rows affected
-- ddl >> resumed
-- ddl >> 0 rows affected
/* txn2:wait */ select * from t3;
-- txn2 >> +----+-------------+-----------+-------------------------+--------------+-------------+--------------+
-- txn2    | ID |      F      |    F1     |            D            |      D1      |     DM      |     DM1      |
-- txn2    +----+-------------+-----------+-------------------------+--------------+-------------+--------------+
-- txn2    |  1 | 3.40282e38  |  34028236 | 1.7976931348623157e308  |  17976921.34 |  9999999999 |  99999999.99 |
-- txn2    |  2 | -2.40282e38 | -24028234 | -1.7876931348623158e308 | -17876921.34 | -9999999998 | -99999998.99 |
-- txn2    | 10 | -3.30282e38 | -34028236 | -1.7976931348623157e308 | -17976921.34 | -9999999999 | -99999999.99 |
-- txn2    |  2 | -2.40282e38 | -24028234 | -1.7876931348623158e308 | -17876921.34 | -9999999998 | -99999998.99 |
-- txn2    |  2 | -2.40282e38 | -24028234 | -1.7876931348623158e308 | -17876921.34 | -9999999998 | -99999998.99 |
-- txn2    +----+-------------+-----------+-------------------------+--------------+-------------+--------------+
/* txn2:wait */ Admin check table t3;
-- txn2 >> 0 rows affected
/* txn2:wait */ drop table t3,t3_test;
-- txn2 >> 0 rows affected

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

test case pass

3. What did you see instead (Required)

2022-09-27 14:32:50 (GMT+8)TiDB tidb-peer:4000[error.go:298] ["2PC failed"] [error="tikv aborts txn: Error(Txn(Error(Mvcc(Error(Kv(Error(Other(\"[components/tikv_kv/src/raftstore_impls.rs:76]: \\"[components/raftstore/src/store/region_snapshot.rs:210]: Key 7480000000000008FF325F698000000000FF0000010380000000FF00000001060A0076FFC465360003800000FF0000000001000000FC is out of [region 41] [7480000000000008FF325F698000000000FF0000010380000000FF00000001060A0076FFC465360003800000FF0000000001000000FD, )\\"\"))))))))"]

4. What is your TiDB version? (Required)

["Git Commit Hash"=ecd67531f1721d3e49eb15a202ac7c0ae02291ec]

seiya-annie commented 2 years ago

tidb.tar.gz

cfzjywxk commented 2 years ago

@seiya-annie tidb_ddl_enable_fast_reorg seems not be released yet? Is it compatible with transaction amend? /cc @wjhuang2016

seiya-annie commented 2 years ago

@Benjamin2037