From 8629d5c108943a50e2b0996ec304d701c3e1a03b Mon Sep 17 00:00:00 2001 From: tangenta Date: Sun, 29 Jan 2023 13:39:27 +0800 Subject: [PATCH 1/3] ddl: move update version function to a proper place --- ddl/index.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ddl/index.go b/ddl/index.go index 221005f58c211..6047de8e4cdf3 100644 --- a/ddl/index.go +++ b/ddl/index.go @@ -793,6 +793,10 @@ func doReorgWorkForCreateIndexMultiSchema(w *worker, d *ddlCtx, t *meta.Meta, jo job.MarkNonRevertible() } // We need another round to wait for all the others sub-jobs to finish. + if err == nil { + ver, err = updateVersionAndTableInfo(d, t, job, tbl.Meta(), true) + return false, ver, err + } return false, ver, err } return true, ver, err @@ -877,7 +881,6 @@ func doReorgWorkForCreateIndex(w *worker, d *ddlCtx, t *meta.Meta, job *model.Jo return false, ver, err } indexInfo.BackfillState = model.BackfillStateInapplicable // Prevent double-write on this index. - ver, err = updateVersionAndTableInfo(d, t, job, tbl.Meta(), true) return true, ver, err default: return false, 0, dbterror.ErrInvalidDDLState.GenWithStackByArgs("backfill", indexInfo.BackfillState) From 2cfcafac92760dbbdb3cbed28ce18074ef59b137 Mon Sep 17 00:00:00 2001 From: tangenta Date: Sun, 29 Jan 2023 13:57:49 +0800 Subject: [PATCH 2/3] address comment --- ddl/index.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ddl/index.go b/ddl/index.go index 6047de8e4cdf3..27cafaac5eabd 100644 --- a/ddl/index.go +++ b/ddl/index.go @@ -791,12 +791,12 @@ func doReorgWorkForCreateIndexMultiSchema(w *worker, d *ddlCtx, t *meta.Meta, jo done, ver, err = doReorgWorkForCreateIndex(w, d, t, job, tbl, indexInfo) if done { job.MarkNonRevertible() + if err == nil { + ver, err = updateVersionAndTableInfo(d, t, job, tbl.Meta(), true) + return true, ver, err + } } // We need another round to wait for all the others sub-jobs to finish. - if err == nil { - ver, err = updateVersionAndTableInfo(d, t, job, tbl.Meta(), true) - return false, ver, err - } return false, ver, err } return true, ver, err From ac8ab3ba114fa349471dadc3a5fdadf939f06c15 Mon Sep 17 00:00:00 2001 From: tangenta Date: Sun, 29 Jan 2023 15:24:29 +0800 Subject: [PATCH 3/3] fix integration test --- ddl/index.go | 1 - 1 file changed, 1 deletion(-) diff --git a/ddl/index.go b/ddl/index.go index 27cafaac5eabd..cc3a3d3795242 100644 --- a/ddl/index.go +++ b/ddl/index.go @@ -793,7 +793,6 @@ func doReorgWorkForCreateIndexMultiSchema(w *worker, d *ddlCtx, t *meta.Meta, jo job.MarkNonRevertible() if err == nil { ver, err = updateVersionAndTableInfo(d, t, job, tbl.Meta(), true) - return true, ver, err } } // We need another round to wait for all the others sub-jobs to finish.