Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion br/pkg/metautil/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ go_test(
],
embed = [":metautil"],
flaky = True,
shard_count = 13,
shard_count = 15,
deps = [
"//br/pkg/utils",
"//pkg/meta/model",
Expand Down
2 changes: 1 addition & 1 deletion lightning/tests/lightning_local_backend/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ grep -Fq 'table(s) [`cpeng`.`a`, `cpeng`.`b`] are not empty' $TEST_DIR/lightning


# First, verify that inject with not leader error is fine.
export GO_FAILPOINTS='github.com/pingcap/tidb/pkg/lightning/backend/local/FailIngestMeta=1*return("notleader");github.com/pingcap/tidb/br/pkg/restore/split/failToSplit=5*return("");github.com/pingcap/tidb/pkg/lightning/backend/local/failToSplit=5*return("")'
export GO_FAILPOINTS='github.com/pingcap/tidb/pkg/lightning/backend/local/FailIngestMeta=1*return("notleader");github.com/pingcap/tidb/br/pkg/restore/split/failToSplit=5*return("");github.com/pingcap/tidb/pkg/lightning/backend/local/forceSplitRegion=5*return("")'
rm -f "$TEST_DIR/lightning-local.log"
run_sql 'DROP DATABASE IF EXISTS cpeng;'
run_lightning --backend local --enable-checkpoint=1 --log-file "$TEST_DIR/lightning-local.log" --config "$CUR/config.toml" -L debug
Expand Down
1 change: 1 addition & 0 deletions pkg/importsdk/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ go_test(
"//pkg/lightning/config",
"//pkg/lightning/log",
"//pkg/lightning/mydump",
"//pkg/parser/ast",
"//pkg/parser/mysql",
"//pkg/util/table-filter",
"@com_github_data_dog_go_sqlmock//:go-sqlmock",
Expand Down
2 changes: 1 addition & 1 deletion pkg/lightning/backend/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ func (local *Backend) prepareAndSendJob(
// the table when table is created.
needSplit := len(regionSplitKeys) > 2 || lfTotalSize > regionSplitSize || lfLength > regionSplitKeyCnt
// split region by given ranges
failpoint.Inject("failToSplit", func(_ failpoint.Value) {
failpoint.Inject("forceSplitRegion", func(_ failpoint.Value) {
needSplit = true
})
if needSplit {
Expand Down
4 changes: 3 additions & 1 deletion pkg/lightning/backend/local/region_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,9 @@ func (d *dispatcher) run() error {
}
// max retry backoff time: 2+4+8+16+30*26=810s
sleepSecond := min(math.Pow(2, float64(job.retryCount)), float64(maxRetryBackoffSecond))
job.waitUntil = time.Now().Add(time.Second * time.Duration(sleepSecond))
backoff := time.Second * time.Duration(sleepSecond)
failpoint.InjectCall("adjustRegionJobRetryBackoff", &backoff)
job.waitUntil = time.Now().Add(backoff)
tidblogutil.Logger(d.workerCtx).Info("put job back to jobCh to retry later",
logutil.Key("startKey", job.keyRange.Start),
logutil.Key("endKey", job.keyRange.End),
Expand Down
19 changes: 19 additions & 0 deletions tests/realtikvtest/addindextest/add_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package addindextest
import (
"sync"
"testing"
"time"

"github.com/pingcap/tidb/pkg/config"
"github.com/pingcap/tidb/pkg/config/kerneltype"
Expand All @@ -35,7 +36,21 @@ func init() {
})
}

func enableFastAddIndexFailpoints(t *testing.T) {
Comment thread
lance6716 marked this conversation as resolved.
t.Helper()
// by split all the time, we can nearly avoid all region job re-queues caused
// by EpochNotMatch or other errors, and can make those cases faster.
// we also reduce the retry backoff to make the test faster when region job
// is re-queued, as CI ENV might be slow and cause more re-queues.
testfailpoint.Enable(t, "github.com/pingcap/tidb/pkg/lightning/backend/local/forceSplitRegion", "return(true)")
testfailpoint.EnableCall(t, "github.com/pingcap/tidb/pkg/lightning/backend/local/adjustRegionJobRetryBackoff",
func(backoff *time.Duration) {
*backoff = time.Second
})
}

func TestCreateNonUniqueIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
testutil.ReduceCheckInterval(t)
var colIDs = [][]int{
{1, 4, 7, 10, 13, 16, 19, 22, 25},
Expand All @@ -47,6 +62,7 @@ func TestCreateNonUniqueIndex(t *testing.T) {
}

func TestCreateUniqueIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
testutil.ReduceCheckInterval(t)
var colIDs [][]int = [][]int{
{1, 6, 7, 8, 11, 13, 15, 16, 18, 19, 22, 26},
Expand All @@ -58,18 +74,21 @@ func TestCreateUniqueIndex(t *testing.T) {
}

func TestCreatePrimaryKey(t *testing.T) {
enableFastAddIndexFailpoints(t)
testutil.ReduceCheckInterval(t)
ctx := testutils.InitTest(t)
testutils.TestOneIndexFrame(ctx, 0, testutils.AddIndexPK)
}

func TestCreateGenColIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
testutil.ReduceCheckInterval(t)
ctx := testutils.InitTest(t)
testutils.TestOneIndexFrame(ctx, 29, testutils.AddIndexGenCol)
}

func TestCreateMultiColsIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
testutil.ReduceCheckInterval(t)
var coliIDs = [][]int{
{1, 4, 7},
Expand Down
5 changes: 5 additions & 0 deletions tests/realtikvtest/addindextest/concurrent_ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
)

func TestConcurrentDDLCreateNonUniqueIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
testutil.ReduceCheckInterval(t)
var colIDs = [][]int{
{1, 4, 7, 10, 13},
Expand All @@ -36,6 +37,7 @@ func TestConcurrentDDLCreateNonUniqueIndex(t *testing.T) {
}

func TestConcurrentDDLCreateUniqueIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
testutil.ReduceCheckInterval(t)
var colIDs = [][]int{
{1, 6, 11, 13},
Expand All @@ -49,6 +51,7 @@ func TestConcurrentDDLCreateUniqueIndex(t *testing.T) {
}

func TestConcurrentDDLCreatePrimaryKey(t *testing.T) {
enableFastAddIndexFailpoints(t)
testutil.ReduceCheckInterval(t)
ctx := testutils.InitConcurrentDDLTest(t, nil, nil, testutils.TestPK)
ctx.CompCtx.Start(ctx)
Expand All @@ -57,6 +60,7 @@ func TestConcurrentDDLCreatePrimaryKey(t *testing.T) {
}

func TestConcurrentDDLCreateGenColIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
testutil.ReduceCheckInterval(t)
ctx := testutils.InitConcurrentDDLTest(t, nil, nil, testutils.TestGenIndex)
ctx.CompCtx.Start(ctx)
Expand All @@ -65,6 +69,7 @@ func TestConcurrentDDLCreateGenColIndex(t *testing.T) {
}

func TestConcurrentDDLCreateMultiColsIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
testutil.ReduceCheckInterval(t)
var coliIDs = [][]int{
{7},
Expand Down
5 changes: 5 additions & 0 deletions tests/realtikvtest/addindextest/failpoints_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
)

func TestFailpointsCreateNonUniqueIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
if !*FullMode {
t.Skip()
}
Expand All @@ -34,6 +35,7 @@ func TestFailpointsCreateNonUniqueIndex(t *testing.T) {
}

func TestFailpointsCreateUniqueIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
if !*FullMode {
t.Skip()
}
Expand All @@ -50,6 +52,7 @@ func TestFailpointsCreatePrimaryKeyFailpoints(t *testing.T) {
if !*FullMode {
t.Skip()
}
enableFastAddIndexFailpoints(t)
ctx := testutils.InitTest(t)
testutils.TestOneIndexFrame(ctx, 0, testutils.AddIndexPK)
}
Expand All @@ -58,11 +61,13 @@ func TestFailpointsCreateGenColIndex(t *testing.T) {
if !*FullMode {
t.Skip()
}
enableFastAddIndexFailpoints(t)
ctx := testutils.InitTestFailpoint(t)
testutils.TestOneIndexFrame(ctx, 29, testutils.AddIndexGenCol)
}

func TestFailpointsCreateMultiColsIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
if !*FullMode {
t.Skip()
}
Expand Down
5 changes: 5 additions & 0 deletions tests/realtikvtest/addindextest/multi_schema_change_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
)

func TestMultiSchemaChangeCreateNonUniqueIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
var colIDs = [][]int{
{1, 4, 7},
{2, 5, 8},
Expand All @@ -32,6 +33,7 @@ func TestMultiSchemaChangeCreateNonUniqueIndex(t *testing.T) {
}

func TestMultiSchemaChangeCreateUniqueIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
var colIDs = [][]int{
{1, 6, 8},
{2, 19},
Expand All @@ -43,18 +45,21 @@ func TestMultiSchemaChangeCreateUniqueIndex(t *testing.T) {
}

func TestMultiSchemaChangeCreatePrimaryKey(t *testing.T) {
enableFastAddIndexFailpoints(t)
ctx := testutils.InitCompCtx(t)
ctx.CompCtx.IsMultiSchemaChange = true
testutils.TestOneIndexFrame(ctx, 0, testutils.AddIndexPK)
}

func TestMultiSchemaChangeCreateGenColIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
ctx := testutils.InitCompCtx(t)
ctx.CompCtx.IsMultiSchemaChange = true
testutils.TestOneIndexFrame(ctx, 29, testutils.AddIndexGenCol)
}

func TestMultiSchemaChangeMultiColsIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
var coliIDs = [][]int{
{1},
{2},
Expand Down
5 changes: 5 additions & 0 deletions tests/realtikvtest/addindextest/pitr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
)

func TestPiTRCreateNonUniqueIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
var colIDs = [][]int{
{1, 4, 7},
{2, 5, 8},
Expand All @@ -32,6 +33,7 @@ func TestPiTRCreateNonUniqueIndex(t *testing.T) {
}

func TestPiTRCreateUniqueIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
var colIDs = [][]int{
{1, 6},
{11},
Expand All @@ -43,18 +45,21 @@ func TestPiTRCreateUniqueIndex(t *testing.T) {
}

func TestPiTRCreatePrimaryKey(t *testing.T) {
enableFastAddIndexFailpoints(t)
ctx := testutils.InitCompCtx(t)
ctx.CompCtx.IsPiTR = true
testutils.TestOneIndexFrame(ctx, 0, testutils.AddIndexPK)
}

func TestPiTRCreateGenColIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
ctx := testutils.InitCompCtx(t)
ctx.CompCtx.IsPiTR = true
testutils.TestOneIndexFrame(ctx, 29, testutils.AddIndexGenCol)
}

func TestPiTRCreateMultiColsIndex(t *testing.T) {
enableFastAddIndexFailpoints(t)
var coliIDs = [][]int{
{1},
{8},
Expand Down
Loading