Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete static recurring tasks before loading them again #433

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/solid_queue/scheduler/recurring_schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def task_keys

private
def persist_tasks
SolidQueue::RecurringTask.static.where.not(key: task_keys).delete_all
SolidQueue::RecurringTask.create_or_update_all configured_tasks
end

Expand Down
4 changes: 2 additions & 2 deletions test/integration/recurring_tasks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ class RecurringTasksTest < ActiveSupport::TestCase
scheduler1 = SolidQueue::Scheduler.new(recurring_tasks: another_task).tap(&:start)
wait_for_registered_processes(6, timeout: 1.second)

assert_recurring_tasks configured_task.merge(another_task)
assert_recurring_tasks another_task

updated_task = { example_task: { class: "AddToBufferJob", schedule: "every minute" } }
scheduler2 = SolidQueue::Scheduler.new(recurring_tasks: updated_task).tap(&:start)
wait_for_registered_processes(7, timeout: 1.second)

assert_recurring_tasks configured_task.merge(updated_task)
assert_recurring_tasks updated_task

terminate_process(@pid)
scheduler1.stop
Expand Down