Open hawkingrei opened 2 months ago
@you06 Is this introduced by the recent refactor?
@you06 Is this introduced by the recent refactor?
This is not introduced by the refactor, I made a reproduce test and found that this race also happens in TiDB 8.1
func TestMemDBRaceInUnionExec(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tables := 5
for i := 0; i < tables; i++ {
tk.MustExec(fmt.Sprintf("create table t%d(id int primary key, v int)", i))
}
tk.MustExec("insert into t0 values(1, 1), (2, 2), (3, 3), (4, 4)")
for i := 1; i < tables; i++ {
tk.MustExec(fmt.Sprintf("insert into t%d select * from t0", i))
}
tk.MustExec("set tidb_pessimistic_txn_fair_locking=0")
for i := 0; i < 1001; i++ {
tk.MustExec("begin pessimistic")
tk.MustQuery(`select * from t0 where id = 1 for update union
select * from t1 where id = 1 for update union
select * from t2 where id = 1 for update union
select * from t3 where id = 1 for update union
select * from t4 where id = 1 for update`)
tk.MustExec("rollback")
}
}
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)