31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/3scale/backend/failed_jobs_scheduler.rb', line 31
def reschedule_failed_jobs
key = dist_lock.lock
ttl_expiration_time = Time.now + TTL_RESCHEDULE_S
rescheduled = failed_while_rescheduling = 0
if key
number_of_jobs_to_reschedule.times do
break unless time_for_another_reschedule?(ttl_expiration_time)
requeue_result = requeue_oldest_failed_job
if requeue_result[:rescheduled?]
rescheduled += 1
else
failed_while_rescheduling += 1
end
requeue_result[:ok_to_remove?] ? remove_oldest_failed_job : break
end
dist_lock.unlock if key == dist_lock.current_lock_key
end
{ rescheduled: rescheduled,
failed_while_rescheduling: failed_while_rescheduling,
failed_current: failed_queue.count }
end
|