Skip to content
Open
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
11 changes: 11 additions & 0 deletions pkg/ddl/backfilling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,17 @@ func assertDistSQLCtxEqual(t *testing.T, expected *distsqlctx.DistSQLContext, ac
require.Equal(t, errctx.NewContextWithLevels(expected.ErrCtx.LevelMap(), expected.WarnHandler), actual.ErrCtx)
}

func TestReorgDistSQLCtxNotFillCache(t *testing.T) {
// Reorg coprocessor scans are single-pass bulk reads and must not pollute the TiKV
// block cache, so NotFillCache is always set on the reorg DistSQLContext.
ctx := newDefaultReorgDistSQLCtx(&mock.Client{}, contextutil.NewStaticWarnHandler(0))
require.True(t, ctx.NotFillCache)

withMeta, err := newReorgDistSQLCtxWithReorgMeta(&mock.Client{}, &model.DDLReorgMeta{}, contextutil.NewStaticWarnHandler(0))
require.NoError(t, err)
require.True(t, withMeta.NotFillCache)
}

func TestValidateAndFillRanges(t *testing.T) {
mkRange := func(start, end string) kv.KeyRange {
return kv.KeyRange{StartKey: []byte(start), EndKey: []byte(end)}
Expand Down
9 changes: 7 additions & 2 deletions pkg/ddl/backfilling_txn_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,13 @@ func newDefaultReorgDistSQLCtx(kvClient kv.Client, warnHandler contextutil.WarnA
var execDetails execdetails.SyncExecDetails
var cpuUsages ppcpuusage.SQLCPUUsages
return &distsqlctx.DistSQLContext{
WarnHandler: warnHandler,
Client: kvClient,
WarnHandler: warnHandler,
Client: kvClient,
// Reorg scans are single-pass bulk reads over the whole table/index range: the blocks
// they touch are never re-read by the reorg, so caching them brings no benefit and can
// evict the working set that concurrent foreground traffic relies on. Skip filling the
// block cache for all reorg coprocessor scans.
NotFillCache: true,
EnableChunkRPC: true,
EnabledRateLimitAction: vardef.DefTiDBEnableRateLimitAction,
KVVars: tikvstore.NewVariables(&sqlKiller.Signal),
Expand Down
Loading