mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
BUGFIX: recovery code in case an unknown job is scheduled
This commit is contained in:
@@ -184,7 +184,11 @@ module Scheduler
|
|||||||
return unless key
|
return unless key
|
||||||
if due.to_i <= Time.now.to_i
|
if due.to_i <= Time.now.to_i
|
||||||
klass = get_klass(key)
|
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 = schedule_info(klass)
|
||||||
info.prev_run = Time.now.to_i
|
info.prev_run = Time.now.to_i
|
||||||
info.prev_result = "QUEUED"
|
info.prev_result = "QUEUED"
|
||||||
|
|||||||
@@ -59,6 +59,13 @@ describe Scheduler::Manager do
|
|||||||
|
|
||||||
describe '#tick' 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
|
it 'should recover from crashed manager' do
|
||||||
|
|
||||||
info = manager.schedule_info(Testing::SuperLongJob)
|
info = manager.schedule_info(Testing::SuperLongJob)
|
||||||
|
|||||||
Reference in New Issue
Block a user