Skip to content

Commit

Permalink
ddl: assign table IDs for jobs submitted to queue (pingcap#54880)
Browse files Browse the repository at this point in the history
  • Loading branch information
tangenta authored Jul 25, 2024
1 parent 6c3e25e commit cf4bb51
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/ddl/ddl_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,20 +326,22 @@ func (d *ddl) addBatchDDLJobs2Queue(jobWs []*JobWrapper) error {
defer d.globalIDLock.Unlock()
return kv.RunInNewTxn(ctx, d.store, true, func(_ context.Context, txn kv.Transaction) error {
t := meta.NewMeta(txn)
ids, err := t.GenGlobalIDs(len(jobWs))

count := getRequiredGIDCount(jobWs)
ids, err := t.GenGlobalIDs(count)
if err != nil {
return errors.Trace(err)
}
assignGIDsForJobs(jobWs, ids)

if err := d.checkFlashbackJobInQueue(t); err != nil {
return errors.Trace(err)
}

for i, jobW := range jobWs {
for _, jobW := range jobWs {
job := jobW.Job
job.Version = currentVersion
job.StartTS = txn.StartTS()
job.ID = ids[i]
setJobStateToQueueing(job)
if err = buildJobDependence(t, job); err != nil {
return errors.Trace(err)
Expand Down

0 comments on commit cf4bb51

Please sign in to comment.