Skip to content

Commit

Permalink
fix the checkLockFile
Browse files Browse the repository at this point in the history
Signed-off-by: Leavrth <[email protected]>
  • Loading branch information
Leavrth committed Jan 16, 2023
1 parent fe88284 commit 1fe6323
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions br/pkg/checkpoint/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,18 +578,20 @@ func (r *CheckpointRunner) checkLockFile(ctx context.Context, now int64) error {
if err != nil {
return errors.Trace(err)
}
if lock.ExpireAt >= now && lock.LockId != r.lockId {
if lock.ExpireAt <= now {
if lock.LockId > r.lockId {
return errors.Errorf("There are another BR(%d) running after but setting lock before this one(%d). "+
"Please check whether the BR is running. If not, you can retry.", lock.LockId, r.lockId)
}
if lock.LockId == r.lockId {
log.Warn("The lock has expired.", zap.Int64("expire-at(ms)", lock.ExpireAt), zap.Int64("now(ms)", now))
}
} else if lock.LockId != r.lockId {
return errors.Errorf("The existing lock will expire in %d seconds. "+
"There may be another BR(%d) running. If not, you can wait for the lock to expire, or delete the file `%s%s` manually.",
(lock.ExpireAt-now)/1000, lock.LockId, strings.TrimRight(r.storage.URI(), "/"), CheckpointLockPath)
}
if lock.LockId > r.lockId {
return errors.Errorf("There are another BR(%d) running after but setting lock before this one(%d). "+
"Please check whether the BR is running. If not, you can retry.", lock.LockId, r.lockId)
}
if lock.LockId == r.lockId {
log.Warn("The lock has expired.", zap.Int64("expire-at(ms)", lock.ExpireAt), zap.Int64("now(ms)", now))
}

return nil
}

Expand Down

0 comments on commit 1fe6323

Please sign in to comment.