docs(HH-626): align Redis claim retry semantics (#171)
Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
@@ -320,10 +320,15 @@ func (wp *WorkerPool) processRedisMessage(ctx context.Context, msg redis.XMessag
|
||||
return
|
||||
}
|
||||
|
||||
// Claim 检查:防止多 consumer 竞争同一 job
|
||||
now := wp.now()
|
||||
if err := archiveExhaustedRetries(wp.db.WithContext(ctx).Where("id = ?", jobID), now); err != nil {
|
||||
applogger.L().Errorf("archive exhausted job %d failed: %v", jobID, err)
|
||||
return
|
||||
}
|
||||
|
||||
// Claim 检查:防止多 consumer 竞争同一 job
|
||||
result := wp.db.WithContext(ctx).Model(&model.BackgroundJob{}).
|
||||
Where("id = ? AND status IN ? AND scheduled_at <= ?",
|
||||
Where("id = ? AND status IN ? AND scheduled_at <= ? AND attempts < max_attempts",
|
||||
jobID,
|
||||
[]string{model.BackgroundJobStatusQueued, model.BackgroundJobStatusRetrying},
|
||||
now,
|
||||
|
||||
Reference in New Issue
Block a user