-
Notifications
You must be signed in to change notification settings - Fork 13
Start process_queue_thread when dead #148
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
dalehamel
left a comment
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.
solid debugging of a gnarly edge case 👏
| end | ||
|
|
||
| def process_queue_thread | ||
| @process_queue_thread ||= Thread.new do |
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.
so this line here is the root of the bug right? This variable is bound already, but the thread is dead, so we call this method but it returns and a new thread is never started
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.
yes
| assert(th.alive?) | ||
| end | ||
|
|
||
| test "process_queue_thread is recreated on enqueue if stopped" do |
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.
I assume this tests fails on the old code right? Just to be 100% sure it's a good regression test
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.
Yes I tested that. Had to add th.join as kill is not instant and the failure was flaky.
manuelfelipe
left a comment
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.
thanks for the fix and the troubleshooting efforts. Fix makes sense when considering our forking strategy
|
tested this in production - fix works. |
Fixes the case when process A starts the background thread and process B is forked from process A. In this case, the old code would not recreate the thread because the thread variable is still there but the thread itself is dead.
We see this a lot in pitchfork because workers are forked from
mold, which I believe/understand is selected from a worker too.