@@ -128,10 +128,6 @@ type jobScheduler struct {
128
128
runningJobs * runningJobs
129
129
sysTblMgr systable.Manager
130
130
schemaLoader SchemaLoader
131
- // currMinJobID is the minimal job ID in tidb_ddl_job table, we use it to mitigate
132
- // this issue https://github.com/pingcap/tidb/issues/52905
133
- currMinJobID int64
134
- lastRefreshMinIDTime time.Time
135
131
136
132
// those fields are created on start
137
133
reorgWorkerPool * workerPool
@@ -198,15 +194,14 @@ func (s *jobScheduler) getJob(se *sess.Session, tp jobType) (*model.Job, error)
198
194
not = ""
199
195
label = "get_job_reorg"
200
196
}
201
- // TODO replace this sub-query with memory implementation.
202
197
const getJobSQL = `select job_meta, processing from mysql.tidb_ddl_job where job_id in
203
- (select min(job_id) from mysql.tidb_ddl_job where job_id >= %d group by schema_ids, table_ids, processing)
198
+ (select min(job_id) from mysql.tidb_ddl_job group by schema_ids, table_ids, processing)
204
199
and %s reorg %s order by processing desc, job_id`
205
200
var excludedJobIDs string
206
201
if ids := s .runningJobs .allIDs (); len (ids ) > 0 {
207
202
excludedJobIDs = fmt .Sprintf ("and job_id not in (%s)" , ids )
208
203
}
209
- sql := fmt .Sprintf (getJobSQL , s . currMinJobID , not , excludedJobIDs )
204
+ sql := fmt .Sprintf (getJobSQL , not , excludedJobIDs )
210
205
rows , err := se .Execute (context .Background (), sql , label )
211
206
if err != nil {
212
207
return nil , errors .Trace (err )
@@ -398,7 +393,6 @@ func (s *jobScheduler) startDispatch() error {
398
393
if err := s .checkAndUpdateClusterState (false ); err != nil {
399
394
continue
400
395
}
401
- s .refreshMinJobID ()
402
396
failpoint .InjectCall ("beforeAllLoadDDLJobAndRun" )
403
397
s .loadDDLJobAndRun (se , s .generalDDLWorkerPool , jobTypeGeneral )
404
398
s .loadDDLJobAndRun (se , s .reorgWorkerPool , jobTypeReorg )
@@ -657,21 +651,6 @@ func (*jobScheduler) markJobProcessing(se *sess.Session, job *model.Job) error {
657
651
return errors .Trace (err )
658
652
}
659
653
660
- func (s * jobScheduler ) refreshMinJobID () {
661
- now := time .Now ()
662
- if now .Sub (s .lastRefreshMinIDTime ) < dispatchLoopWaitingDuration {
663
- return
664
- }
665
- s .lastRefreshMinIDTime = now
666
- minID , err := s .sysTblMgr .GetMinJobID (s .schCtx , s .currMinJobID )
667
- if err != nil {
668
- logutil .DDLLogger ().Info ("get min job ID failed" , zap .Error (err ))
669
- return
670
- }
671
- // use max, in case all job are finished to avoid the currMinJobID go back.
672
- s .currMinJobID = max (s .currMinJobID , minID )
673
- }
674
-
675
654
func (d * ddl ) getTableByTxn (r autoid.Requirement , schemaID , tableID int64 ) (* model.DBInfo , table.Table , error ) {
676
655
var tbl table.Table
677
656
var dbInfo * model.DBInfo
0 commit comments