Skip to content

Commit

Permalink
upgrade: add a variable to make insert ddl job force to queue (#36614) (
Browse files Browse the repository at this point in the history
#36618)

close #36601
  • Loading branch information
ti-srebot authored Jul 27, 2022
1 parent 65f7e2e commit 6d76293
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ddl/ddl_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ func (d *ddl) limitDDLJobs() {
func (d *ddl) addBatchDDLJobs(tasks []*limitJobTask) {
startTime := time.Now()
var err error
if variable.EnableConcurrentDDL.Load() {
// DDLForce2Queue is a flag to tell DDL worker to always push the job to the DDL queue.
if variable.EnableConcurrentDDL.Load() && !variable.DDLForce2Queue.Load() {
err = d.addBatchDDLJobs2Table(tasks)
} else {
err = d.addBatchDDLJobs2Queue(tasks)
Expand Down
7 changes: 4 additions & 3 deletions session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -789,16 +789,17 @@ func upgrade(s Session) {
}
// Only upgrade from under version92 and this TiDB is not owner set.
// The owner in older tidb does not support concurrent DDL, we should add the internal DDL to job queue.
original := variable.EnableConcurrentDDL.Load()
if ver < version92 && !domain.GetDomain(s).DDL().OwnerManager().IsOwner() {
variable.EnableConcurrentDDL.Store(false)
// use another variable DDLForce2Queue but not EnableConcurrentDDL since in upgrade it may set global variable, the initial step will
// overwrite variable EnableConcurrentDDL.
variable.DDLForce2Queue.Store(true)
}
// Do upgrade works then update bootstrap version.
for _, upgrade := range bootstrapVersion {
upgrade(s, ver)
}

variable.EnableConcurrentDDL.Store(original)
variable.DDLForce2Queue.Store(false)
updateBootstrapVer(s)
ctx := kv.WithInternalSourceType(context.Background(), kv.InternalTxnBootstrap)
_, err = s.ExecuteInternal(ctx, "COMMIT")
Expand Down
1 change: 1 addition & 0 deletions sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ var (
PreparedPlanCacheSize = atomic.NewUint64(DefTiDBPrepPlanCacheSize)
PreparedPlanCacheMemoryGuardRatio = atomic.NewFloat64(DefTiDBPrepPlanCacheMemoryGuardRatio)
EnableConcurrentDDL = atomic.NewBool(DefTiDBEnableConcurrentDDL)
DDLForce2Queue = atomic.NewBool(false)
EnableNoopVariables = atomic.NewBool(DefTiDBEnableNoopVariables)
)

Expand Down

0 comments on commit 6d76293

Please sign in to comment.