@@ -32,7 +32,7 @@ import (
32
32
)
33
33
34
34
const insertNewTableIntoStatusTemplate = "INSERT INTO mysql.tidb_ttl_table_status (table_id,parent_table_id) VALUES (%d, %d)"
35
- const setTableStatusOwnerTemplate = "UPDATE mysql.tidb_ttl_table_status SET current_job_id = UUID(), current_job_owner_id = '%s',current_job_start_time = '%s',current_job_status = 'waiting',current_job_status_update_time = '%s',current_job_ttl_expire = '%s',current_job_owner_hb_time = '%s' WHERE (current_job_owner_id IS NULL OR current_job_owner_hb_time < '%s') AND table_id = %d"
35
+ const setTableStatusOwnerTemplate = "UPDATE mysql.tidb_ttl_table_status SET current_job_id = UUID(), current_job_owner_id = '%s',current_job_start_time = '%s',current_job_status = 'waiting',current_job_status_update_time = '%s',current_job_ttl_expire = '%s',current_job_owner_hb_time = '%s' WHERE table_id = %d"
36
36
const updateHeartBeatTemplate = "UPDATE mysql.tidb_ttl_table_status SET current_job_owner_hb_time = '%s' WHERE table_id = %d AND current_job_owner_id = '%s'"
37
37
38
38
const timeFormat = "2006-01-02 15:04:05"
@@ -41,8 +41,8 @@ func insertNewTableIntoStatusSQL(tableID int64, parentTableID int64) string {
41
41
return fmt .Sprintf (insertNewTableIntoStatusTemplate , tableID , parentTableID )
42
42
}
43
43
44
- func setTableStatusOwnerSQL (tableID int64 , now time.Time , currentJobTTLExpire time.Time , maxHBTime time. Time , id string ) string {
45
- return fmt .Sprintf (setTableStatusOwnerTemplate , id , now .Format (timeFormat ), now .Format (timeFormat ), currentJobTTLExpire .Format (timeFormat ), now .Format (timeFormat ), maxHBTime . Format ( timeFormat ), tableID )
44
+ func setTableStatusOwnerSQL (tableID int64 , now time.Time , currentJobTTLExpire time.Time , id string ) string {
45
+ return fmt .Sprintf (setTableStatusOwnerTemplate , id , now .Format (timeFormat ), now .Format (timeFormat ), currentJobTTLExpire .Format (timeFormat ), now .Format (timeFormat ), tableID )
46
46
}
47
47
48
48
func updateHeartBeatSQL (tableID int64 , now time.Time , id string ) string {
@@ -492,11 +492,10 @@ func (m *JobManager) couldTrySchedule(table *cache.TableStatus, now time.Time) b
492
492
// localJob and return it.
493
493
// It could be nil, nil, if the table query doesn't return error but the job has been locked by other instances.
494
494
func (m * JobManager ) lockNewJob (ctx context.Context , se session.Session , table * cache.PhysicalTable , now time.Time ) (* ttlJob , error ) {
495
- maxHBTime := now .Add (- 2 * jobManagerLoopTickerInterval )
496
495
var expireTime time.Time
497
496
498
497
err := se .RunInTxn (ctx , func () error {
499
- rows , err := se .ExecuteSQL (ctx , cache .SelectFromTTLTableStatusWithID (table .TableInfo . ID ))
498
+ rows , err := se .ExecuteSQL (ctx , cache .SelectFromTTLTableStatusWithID (table .ID ))
500
499
if err != nil {
501
500
return err
502
501
}
@@ -506,7 +505,7 @@ func (m *JobManager) lockNewJob(ctx context.Context, se session.Session, table *
506
505
if err != nil {
507
506
return err
508
507
}
509
- rows , err = se .ExecuteSQL (ctx , cache .SelectFromTTLTableStatusWithID (table .TableInfo . ID ))
508
+ rows , err = se .ExecuteSQL (ctx , cache .SelectFromTTLTableStatusWithID (table .ID ))
510
509
if err != nil {
511
510
return err
512
511
}
@@ -527,7 +526,7 @@ func (m *JobManager) lockNewJob(ctx context.Context, se session.Session, table *
527
526
return err
528
527
}
529
528
530
- _ , err = se .ExecuteSQL (ctx , setTableStatusOwnerSQL (table .ID , now , expireTime , maxHBTime , m .id ))
529
+ _ , err = se .ExecuteSQL (ctx , setTableStatusOwnerSQL (table .ID , now , expireTime , m .id ))
531
530
532
531
return err
533
532
})
0 commit comments