Skip to content

non-DXF ADD INDEX of large table (trigger import due to disk quota) will write KV with TS = 0 #57980

@lance6716

Description

@lance6716

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

use this diff to trigger disk quota import on small tables

diff --git a/pkg/ddl/ingest/backend.go b/pkg/ddl/ingest/backend.go
index f11849f70b..cd08ec14c5 100644
--- a/pkg/ddl/ingest/backend.go
+++ b/pkg/ddl/ingest/backend.go
@@ -187,6 +187,8 @@ func (bc *litBackendCtx) Flush(indexID int64, mode FlushMode) (flushed, imported
        }

        shouldFlush, shouldImport := bc.checkFlush(mode)
+       shouldFlush = true
+       shouldImport = true
        if !shouldFlush {
                return false, false, nil
        }

and print TS used in import, or check TiKV

run TestAddIndexRemoteDuplicateCheck with the change, or other ADD INDEX that can trigger disk-quota import

diff --git a/tests/realtikvtest/addindextest4/ingest_test.go b/tests/realtikvtes
t/addindextest4/ingest_test.go
index 2e393ce4f8..7a3f91f031 100644
--- a/tests/realtikvtest/addindextest4/ingest_test.go
+++ b/tests/realtikvtest/addindextest4/ingest_test.go
@@ -407,7 +407,8 @@ func TestAddIndexRemoteDuplicateCheck(t *testing.T) {
        tk.MustExec("insert into t values(100000, 1, 1);")

        ingest.ForceSyncFlagForTest = true
-       tk.MustGetErrCode("alter table t add unique index idx(b);", errno.ErrDupEntry)
+       tk.MustExec("alter table t add index idx_test(b);")
+       //tk.MustGetErrCode("alter table t add unique index idx(b);", errno.ErrDupEntry)
        ingest.ForceSyncFlagForTest = false

        tk.MustExec("set global tidb_ddl_reorg_worker_cnt=4;")

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

no error

3. What did you see instead (Required)

TiKV panic due to it has data with TS = 0

4. What is your TiDB version? (Required)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions