mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
BUGFIX: recovery code in case an unknown job is scheduled
This commit is contained in:
parent
a05606d1ff
commit
5c3f2feed4
2 changed files with 12 additions and 1 deletions
|
@ -184,7 +184,11 @@ module Scheduler
|
|||
return unless key
|
||||
if due.to_i <= Time.now.to_i
|
||||
klass = get_klass(key)
|
||||
return unless klass
|
||||
unless klass
|
||||
# corrupt key, nuke it (renamed job or something)
|
||||
redis.zrem Manager.queue_key, key
|
||||
return
|
||||
end
|
||||
info = schedule_info(klass)
|
||||
info.prev_run = Time.now.to_i
|
||||
info.prev_result = "QUEUED"
|
||||
|
|
|
@ -59,6 +59,13 @@ describe Scheduler::Manager do
|
|||
|
||||
describe '#tick' do
|
||||
|
||||
it 'should nuke missing jobs' do
|
||||
$redis.zadd Scheduler::Manager.queue_key, Time.now.to_i - 1000, "BLABLA"
|
||||
manager.tick
|
||||
$redis.zcard(Scheduler::Manager.queue_key).should == 0
|
||||
|
||||
end
|
||||
|
||||
it 'should recover from crashed manager' do
|
||||
|
||||
info = manager.schedule_info(Testing::SuperLongJob)
|
||||
|
|
Loading…
Reference in a new issue