From 6990c1f18f1a2066cf5ba4bc08b2a02b3d5965e1 Mon Sep 17 00:00:00 2001 From: tangenta Date: Tue, 30 Jul 2024 19:40:19 +0800 Subject: [PATCH] ddl: remove reorg ctx when current instance is not owner (#55050) close pingcap/tidb#54897 --- pkg/ddl/backfilling.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/ddl/backfilling.go b/pkg/ddl/backfilling.go index 33155f01e07a7..450499bbf200b 100644 --- a/pkg/ddl/backfilling.go +++ b/pkg/ddl/backfilling.go @@ -674,8 +674,12 @@ func (dc *ddlCtx) writePhysicalTableRecord(sessPool *sess.Pool, t table.Physical totalAddedCount := job.GetRowCount() startKey, endKey := reorgInfo.StartKey, reorgInfo.EndKey - if err := dc.isReorgRunnable(reorgInfo.Job.ID, false); err != nil { + if errors.ErrorEqual(err, dbterror.ErrNotOwner) { + // This instance is not DDL owner, we remove reorgctx proactively + // to avoid being used later. + dc.removeReorgCtx(reorgInfo.ID) + } return errors.Trace(err) }