-
Notifications
You must be signed in to change notification settings - Fork 206
Attempt to reduce flakiness of recurring_tasks_test
#684
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
Conversation
393f0ec to
7ee0213
Compare
7ee0213 to
f99a756
Compare
|
Green CI = instant dopamine 🤩 |
| SolidQueue::Process.destroy_all | ||
| SolidQueue::Job.destroy_all | ||
| SolidQueue::RecurringTask.delete_all | ||
| JobResult.delete_all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this from teardown since it's already handled in test_helper.rb teardown
|
|
||
| terminate_process(pid) | ||
| wait_for_registered_processes(0, timeout: SolidQueue.shutdown_timeout) | ||
| sleep SolidQueue.shutdown_timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this extra sleep necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! I guess I was being extra cautious while debugging this, it seemed worth it because shutdown_timeout is only 2 seconds. But I tested locally and it runs fine without it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense! Thank you so much!
| end | ||
| end | ||
|
|
||
| # no need to stop @pid supervisor - that will be handled in teardown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I think we can remove this comment, as I think most people won't wonder about this 🤔
Issue: #602
Flake: recurring_tasks_test.rb
Failed run: https://github.com/rails/solid_queue/actions/runs/18916883193/job/54002506057
Instructions to validate the fix locally: #678
Summary
I found a race condition in recurring_tasks_test.rb which tries to stop the supervisor twice. Once inside the test and once again in
teardown.When synchronized enough, the first shutdown worked, and the second one tried to stop a process that had already exited. That second attempt escalated to a
KILLinstead of a cleanTERM, which is why the assertion failed in CI.The fix makes sure we only stop the supervisor once, removing the double-shutdown race.