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
3 changes: 2 additions & 1 deletion pkg/ddl/reorg_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ func initJobReorgMetaFromVariables(ctx context.Context, job *model.Job, tbl tabl
// we don't use DXF service for bootstrap/upgrade related DDL, so no need to
// calculate resources.
initing := sctx.Value(sessionctx.Initing) != nil
shouldCalResource := kerneltype.IsNextGen() && !initing
// some mock context may not have store, such as the schema tracker test.
shouldCalResource := kerneltype.IsNextGen() && !initing && sctx.GetStore() != nil
if (setReorgParam || setDistTaskParam) && shouldCalResource {
tableSizeInBytes = getTableSizeByID(ctx, sctx.GetStore(), tbl)
var err error
Expand Down
4 changes: 2 additions & 2 deletions pkg/executor/importer/importer_testkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,14 +431,14 @@ func TestCalResourceParams(t *testing.T) {
_, tm, ctx := testutil.InitTableTest(t)

require.NoError(t, tm.InitMeta(ctx, "tidb1", handle.GetTargetScope()))
c := &importer.LoadDataController{Plan: &importer.Plan{TotalFileSize: 200 * units.TiB}}
c := &importer.LoadDataController{Plan: &importer.Plan{TotalFileSize: 200 * units.TiB, TableInfo: &model.TableInfo{}}}
importer.WithLogger(zap.NewNop())(c)
require.NoError(t, c.CalResourceParams(ctx))
require.Equal(t, 8, c.ThreadCnt)
require.Equal(t, 32, c.MaxNodeCnt)
require.Equal(t, 256, c.DistSQLScanConcurrency)

c = &importer.LoadDataController{Plan: &importer.Plan{TotalFileSize: 300 * units.GiB}}
c = &importer.LoadDataController{Plan: &importer.Plan{TotalFileSize: 300 * units.GiB, TableInfo: &model.TableInfo{}}}
importer.WithLogger(zap.NewNop())(c)
require.NoError(t, c.CalResourceParams(ctx))
require.Equal(t, 8, c.ThreadCnt)
Expand Down
7 changes: 7 additions & 0 deletions pkg/session/test/bootstraptest/bootstrap_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ func TestUpgradeWithPauseDDL(t *testing.T) {
wg := sync.WaitGroup{}
execDDL := func(query string) {
tk := testkit.NewTestKit(t, store)
tk.Session().SetValue(sessionctx.Initing, true)
tk.MustExec("use test")
_, err := tk.ExecWithContext(context.Background(), query)
require.NoError(t, err)
Expand All @@ -725,6 +726,12 @@ func TestUpgradeWithPauseDDL(t *testing.T) {
defer wg.Done()
ch <- struct{}{}
tk := testkit.NewTestKit(t, store)
// we are running DDL on user table, it's not possible in normal
// upgrade process, we only use it to mock that another instance
// submits a DDL job on user table.
// we have to set sessionctx.Initing to avoid nextgen calculate resource
// params for this DDL.
tk.Session().SetValue(sessionctx.Initing, true)
tk.MustExec("use test")
_, err := tk.ExecWithContext(context.Background(), query)
if err != nil {
Expand Down