Skip to content

Commit

Permalink
This is an automated cherry-pick of #44768
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
lcwangchao authored and ti-chi-bot committed Jun 21, 2023
1 parent f5b4ba5 commit b0f5301
Show file tree
Hide file tree
Showing 3 changed files with 702 additions and 4 deletions.
20 changes: 19 additions & 1 deletion ttl/ttlworker/job_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ func insertNewTableIntoStatusSQL(tableID int64, parentTableID int64) (string, []
return insertNewTableIntoStatusTemplate, []interface{}{tableID, parentTableID}
}

<<<<<<< HEAD
func setTableStatusOwnerSQL(jobID string, tableID int64, now time.Time, currentJobTTLExpire time.Time, id string) (string, []interface{}) {
return setTableStatusOwnerTemplate, []interface{}{jobID, id, now.Format(timeFormat), now.Format(timeFormat), currentJobTTLExpire.Format(timeFormat), now.Format(timeFormat), tableID}
=======
func setTableStatusOwnerSQL(uuid string, tableID int64, jobStart time.Time, now time.Time, currentJobTTLExpire time.Time, id string) (string, []interface{}) {
return setTableStatusOwnerTemplate, []interface{}{uuid, id, jobStart, now.Format(timeFormat), currentJobTTLExpire.Format(timeFormat), now.Format(timeFormat), tableID}
>>>>>>> 689bedf824d (ttl: fix ttl job start time will be override after failover (#44768))
}

func updateHeartBeatSQL(tableID int64, now time.Time, id string) (string, []interface{}) {
Expand Down Expand Up @@ -548,11 +553,24 @@ func (m *JobManager) lockNewJob(ctx context.Context, se session.Session, table *
}

jobID = uuid.New().String()
<<<<<<< HEAD
=======
jobStart := now
jobExist := false
if len(tableStatus.CurrentJobID) > 0 {
// don't create new job if there is already one running
// so the running tasks don't need to be cancelled
jobID = tableStatus.CurrentJobID
expireTime = tableStatus.CurrentJobTTLExpire
jobStart = tableStatus.CurrentJobStartTime
jobExist = true
}
>>>>>>> 689bedf824d (ttl: fix ttl job start time will be override after failover (#44768))
failpoint.Inject("set-job-uuid", func(val failpoint.Value) {
jobID = val.(string)
})

sql, args = setTableStatusOwnerSQL(jobID, table.ID, now, expireTime, m.id)
sql, args = setTableStatusOwnerSQL(jobID, table.ID, jobStart, now, expireTime, m.id)
_, err = se.ExecuteSQL(ctx, sql, args...)
return errors.Wrapf(err, "execute sql: %s", sql)
})
Expand Down
Loading

0 comments on commit b0f5301

Please sign in to comment.