Skip to content

Commit 953349c

Browse files
committed
Don't delete persisted recurring tasks when the dispatcher shuts down
1 parent c2ec696 commit 953349c

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

lib/solid_queue/dispatcher/recurring_schedule.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def schedule_task(task)
3333
def unschedule_tasks
3434
scheduled_tasks.values.each(&:cancel)
3535
scheduled_tasks.clear
36-
37-
wrap_in_app_executor { delete_tasks }
3836
end
3937

4038
def task_keys
@@ -50,10 +48,6 @@ def reload_tasks
5048
@configured_tasks = SolidQueue::RecurringTask.where(key: task_keys)
5149
end
5250

53-
def delete_tasks
54-
SolidQueue::RecurringTask.static.delete_all
55-
end
56-
5751
def schedule(task)
5852
scheduled_task = Concurrent::ScheduledTask.new(task.delay_from_now, args: [ self, task, task.next_time ]) do |thread_schedule, thread_task, thread_task_run_at|
5953
thread_schedule.schedule_task(thread_task)

test/integration/recurring_tasks_test.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ class RecurringTasksTest < ActiveSupport::TestCase
4848

4949
assert_recurring_tasks configured_task
5050
terminate_process(@pid)
51-
assert_recurring_tasks []
5251

53-
SolidQueue::RecurringTask.create!(key: "periodic_store_result", class_name: "StoreResultJob", schedule: "every minute", arguments: [ 42 ])
52+
task = SolidQueue::RecurringTask.find_by(key: "periodic_store_result")
53+
task.update!(class_name: "StoreResultJob", schedule: "every minute", arguments: [ 42 ])
5454

5555
@pid = run_supervisor_as_fork
5656
wait_for_registered_processes(4, timeout: 3.second)
@@ -75,8 +75,6 @@ class RecurringTasksTest < ActiveSupport::TestCase
7575
terminate_process(@pid)
7676
dispatcher1.stop
7777
dispatcher2.stop
78-
79-
assert_recurring_tasks []
8078
end
8179

8280
private

0 commit comments

Comments
 (0)