@@ -348,10 +348,10 @@ func TestAddIndexSplitTableRanges(t *testing.T) {
348348 }
349349 tk .MustQuery ("split table t between (0) and (80000) regions 7;" ).Check (testkit .Rows ("6 1" ))
350350
351- ddl . SetBackfillTaskChanSizeForTest ( 4 )
351+ testfailpoint . Enable ( t , "github.com/pingcap/tidb/pkg/ddl/setLimitForLoadTableRanges" , "return(4)" )
352352 tk .MustExec ("alter table t add index idx(b);" )
353353 tk .MustExec ("admin check table t;" )
354- ddl . SetBackfillTaskChanSizeForTest ( 7 )
354+ testfailpoint . Enable ( t , "github.com/pingcap/tidb/pkg/ddl/setLimitForLoadTableRanges" , "return(7)" )
355355 tk .MustExec ("alter table t add index idx_2(b);" )
356356 tk .MustExec ("admin check table t;" )
357357
@@ -361,10 +361,37 @@ func TestAddIndexSplitTableRanges(t *testing.T) {
361361 tk .MustExec (fmt .Sprintf ("insert into t values (%d, %d);" , i * 10000 , i * 10000 ))
362362 }
363363 tk .MustQuery ("split table t by (10000),(20000),(30000),(40000),(50000),(60000);" ).Check (testkit .Rows ("6 1" ))
364- ddl .SetBackfillTaskChanSizeForTest (4 )
364+ testfailpoint .Enable (t , "github.com/pingcap/tidb/pkg/ddl/setLimitForLoadTableRanges" , "return(4)" )
365+ tk .MustExec ("alter table t add unique index idx(b);" )
366+ tk .MustExec ("admin check table t;" )
367+ }
368+
369+ func TestAddIndexLoadTableRangeError (t * testing.T ) {
370+ store := realtikvtest .CreateMockStoreAndSetup (t )
371+ tk := testkit .NewTestKit (t , store )
372+ tk .MustExec ("drop database if exists addindexlit;" )
373+ tk .MustExec ("create database addindexlit;" )
374+ tk .MustExec ("use addindexlit;" )
375+ tk .MustExec (`set global tidb_ddl_enable_fast_reorg=on;` )
376+ tk .MustExec (`set global tidb_enable_dist_task=off;` ) // Use checkpoint manager.
377+
378+ tk .MustExec ("create table t (a int primary key, b int);" )
379+ for i := 0 ; i < 8 ; i ++ {
380+ tk .MustExec (fmt .Sprintf ("insert into t values (%d, %d);" , i * 10000 , i * 10000 ))
381+ }
382+ tk .MustQuery ("split table t by (10000),(20000),(30000),(40000),(50000),(60000);" ).Check (testkit .Rows ("6 1" ))
383+
384+ testfailpoint .Enable (t , "github.com/pingcap/tidb/pkg/ddl/setLimitForLoadTableRanges" , "return(3)" )
385+ var batchCnt int
386+ testfailpoint .EnableCall (t , "github.com/pingcap/tidb/pkg/ddl/beforeLoadRangeFromPD" , func (mockErr * bool ) {
387+ batchCnt ++
388+ if batchCnt == 2 {
389+ * mockErr = true
390+ }
391+ })
392+ testfailpoint .Enable (t , "github.com/pingcap/tidb/pkg/ddl/ingest/forceSyncFlagForTest" , "return" )
365393 tk .MustExec ("alter table t add unique index idx(b);" )
366394 tk .MustExec ("admin check table t;" )
367- ddl .SetBackfillTaskChanSizeForTest (1024 )
368395}
369396
370397func TestAddIndexMockFlushError (t * testing.T ) {
0 commit comments