Skip to content

Commit a53d3cc

Browse files
tangentati-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#44442
Signed-off-by: ti-chi-bot <[email protected]>
1 parent 9da9d4d commit a53d3cc

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

br/pkg/lightning/backend/local/duplicate.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,8 +635,9 @@ func (m *DupeDetector) buildIndexDupTasks() ([]dupTask, error) {
635635
tid := tablecodec.DecodeTableID(ranges[0].StartKey)
636636
for _, r := range ranges {
637637
tasks = append(tasks, dupTask{
638-
KeyRange: r,
639-
tableID: tid,
638+
KeyRange: r,
639+
tableID: tid,
640+
indexInfo: indexInfo,
640641
})
641642
}
642643
})

ddl/ingest/backend.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,11 @@ func (bc *litBackendCtx) Flush(indexID int64, mode FlushMode) (flushed, imported
224224
return true, true, nil
225225
}
226226

227+
// ForceSyncFlagForTest is a flag to force sync only for test.
228+
var ForceSyncFlagForTest = false
229+
227230
func (bc *litBackendCtx) ShouldSync(mode FlushMode) (shouldFlush bool, shouldImport bool) {
228-
if mode == FlushModeForceGlobal {
231+
if mode == FlushModeForceGlobal || ForceSyncFlagForTest {
229232
return true, true
230233
}
231234
if mode == FlushModeForceLocal {

tests/realtikvtest/addindextest/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,13 @@ go_test(
3838
"//ddl",
3939
"//ddl/ingest",
4040
"//ddl/testutil",
41+
<<<<<<< HEAD
4142
"//domain",
4243
"//errno",
4344
"//parser/model",
45+
=======
46+
"//errno",
47+
>>>>>>> cd0f864f714 (lightning/backend/local: fix `buildIndexDupTasks` (#44442))
4448
"//sessionctx/variable",
4549
"//testkit",
4650
"//tests/realtikvtest",

tests/realtikvtest/addindextest/integration_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ import (
2727
"github.com/pingcap/tidb/ddl"
2828
"github.com/pingcap/tidb/ddl/ingest"
2929
"github.com/pingcap/tidb/ddl/testutil"
30+
<<<<<<< HEAD
3031
"github.com/pingcap/tidb/domain"
3132
"github.com/pingcap/tidb/errno"
3233
"github.com/pingcap/tidb/parser/model"
34+
=======
35+
"github.com/pingcap/tidb/errno"
36+
>>>>>>> cd0f864f714 (lightning/backend/local: fix `buildIndexDupTasks` (#44442))
3337
"github.com/pingcap/tidb/sessionctx/variable"
3438
"github.com/pingcap/tidb/testkit"
3539
"github.com/pingcap/tidb/tests/realtikvtest"
@@ -455,6 +459,7 @@ func TestAddIndexFinishImportError(t *testing.T) {
455459
require.True(t, strings.Contains(jobTp, "ingest"), jobTp)
456460
}
457461

462+
<<<<<<< HEAD
458463
func (c *testCallback) OnJobRunAfter(job *model.Job) {
459464
if c.OnJobRunAfterExported != nil {
460465
c.OnJobRunAfterExported(job)
@@ -523,16 +528,32 @@ func TestAddIndexBackfillLostUpdate(t *testing.T) {
523528
}
524529

525530
func TestAddIndexPreCheckFailed(t *testing.T) {
531+
=======
532+
func TestAddIndexRemoteDuplicateCheck(t *testing.T) {
533+
>>>>>>> cd0f864f714 (lightning/backend/local: fix `buildIndexDupTasks` (#44442))
526534
store := realtikvtest.CreateMockStoreAndSetup(t)
527535
tk := testkit.NewTestKit(t, store)
528536
tk.MustExec("drop database if exists addindexlit;")
529537
tk.MustExec("create database addindexlit;")
530538
tk.MustExec("use addindexlit;")
531539
tk.MustExec(`set global tidb_ddl_enable_fast_reorg=on;`)
540+
<<<<<<< HEAD
532541

533542
tk.MustExec("create table t(id int primary key, b int, k int);")
534543
tk.MustExec("insert into t values (1, 1, 1);")
535544
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/ddl/ingest/mockIngestCheckEnvFailed", "return"))
536545
tk.MustGetErrMsg("alter table t add index idx(b);", "[ddl:8256]Check ingest environment failed: mock error")
537546
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/ddl/ingest/mockIngestCheckEnvFailed"))
547+
=======
548+
tk.MustExec("set global tidb_ddl_reorg_worker_cnt=1;")
549+
550+
tk.MustExec("create table t(id int primary key, b int, k int);")
551+
tk.MustQuery("split table t by (30000);").Check(testkit.Rows("1 1"))
552+
tk.MustExec("insert into t values(1, 1, 1);")
553+
tk.MustExec("insert into t values(100000, 1, 1);")
554+
555+
ingest.ForceSyncFlagForTest = true
556+
tk.MustGetErrCode("alter table t add unique index idx(b);", errno.ErrDupEntry)
557+
ingest.ForceSyncFlagForTest = false
558+
>>>>>>> cd0f864f714 (lightning/backend/local: fix `buildIndexDupTasks` (#44442))
538559
}

0 commit comments

Comments
 (0)