pingcap / tidb

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

Report unexpected duplicate when update partition tables during add column. #57588

Closed Defined2014 closed 8 hours ago

Defined2014 commented 1 day ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

func TestUpdateMultiplePartitionTable(t *testing.T) {
    store := testkit.CreateMockStore(t)
    tk := testkit.NewTestKit(t, store)
    tk.MustExec("use test")
    tk.MustExec("create table t1 (c1 int, c2 int) partition by hash (c1) partitions 16")
    tk.MustExec("insert t1 values (1, 1), (2, 2)")
    tk.MustExec("create table t2 (c1 int, c2 int) partition by hash (c1) partitions 16")
    tk.MustExec("insert t2 values (1, 3), (2, 5)")
    tk2 := testkit.NewTestKit(t, store)
    tk2.MustExec("use test")

    testfailpoint.EnableCall(t, "github.com/pingcap/tidb/pkg/ddl/onJobUpdated", func(job *model.Job) {
        if job.SchemaState == model.StateWriteOnly {
            tk2.MustExec("update t1, t2 set t1.c1 = 8, t2.c2 = 10 where t1.c2 = t2.c1")
            tk2.MustQuery("select * from t1").Sort().Check(testkit.Rows("8 1", "8 2"))
            tk2.MustQuery("select * from t2").Sort().Check(testkit.Rows("1 10", "2 10"))
        }
    })

    tk.MustExec("alter table t1 add column c3 bigint default 9")

    tk.MustQuery("select * from t1").Sort().Check(testkit.Rows("8 1 9", "8 2 9"))
}

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

test pass

3. What did you see instead (Required)

test failed

4. What is your TiDB version? (Required)