From d84e1d2461d637ca9b32abfd06cc7b067833f72a Mon Sep 17 00:00:00 2001 From: Lynn Date: Mon, 20 Nov 2023 18:59:41 +0800 Subject: [PATCH] ddl: we shouldn't make a DDL job to a dist task when it's on system DB in upgrading (#48716) close pingcap/tidb#48706 --- pkg/ddl/index.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/ddl/index.go b/pkg/ddl/index.go index 2fd12e3825005..0d8020d09450f 100644 --- a/pkg/ddl/index.go +++ b/pkg/ddl/index.go @@ -771,22 +771,28 @@ func pickBackfillType(ctx context.Context, job *model.Job, unique bool, d *ddlCt return model.ReorgTypeNone, err } var pdLeaderAddr string + var isUpgradingSysDB bool if d != nil { //nolint:forcetypeassert pdLeaderAddr = d.store.(tikv.Storage).GetRegionCache().PDClient().GetLeaderAddr() + isUpgradingSysDB = d.stateSyncer.IsUpgradingState() && hasSysDB(job) } - if variable.EnableDistTask.Load() { + useDistReorg := false + if variable.EnableDistTask.Load() && !isUpgradingSysDB { _, err = ingest.LitBackCtxMgr.Register(ctx, unique, job.ID, d.etcdCli, pdLeaderAddr, job.ReorgMeta.ResourceGroupName) + useDistReorg = true } else { _, err = ingest.LitBackCtxMgr.Register(ctx, unique, job.ID, nil, pdLeaderAddr, job.ReorgMeta.ResourceGroupName) + if isUpgradingSysDB { + logutil.BgLogger().Info("pick backfill type, cannot be a dist task because the job on the system DB in the upgrade state", + zap.String("category", "ddl"), zap.Stringer("job", job)) + } } if err != nil { return model.ReorgTypeNone, err } job.ReorgMeta.ReorgTp = model.ReorgTypeLitMerge - if variable.EnableDistTask.Load() { - job.ReorgMeta.IsDistReorg = true - } + job.ReorgMeta.IsDistReorg = useDistReorg return model.ReorgTypeLitMerge, nil } }