From 02d8ff7aa81c70d3a18c36c76e60f19202a6f755 Mon Sep 17 00:00:00 2001 From: tangenta Date: Tue, 30 Jul 2024 15:37:09 +0800 Subject: [PATCH] ddl: remove reorg ctx when current instance is not owner --- 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) }