-
Notifications
You must be signed in to change notification settings - Fork 897
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
Fix smartproxy worker heartbeat thread #19816
Conversation
The heartbeat worker thread and the main thread were competing to define the Workers::MiqDefaults constant. The main thread calls heartbeat from do_work_loop which is unavoidable. So to solve the problem we just wait until the first call to do_work to start the heartbeat worker. This allows the main thread to resolve the constant without contention and the heartbeat worker still gets started before we process the first queue message Fixes ManageIQ#19813
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.
Code makes sense, and I just tested SSA end-to-end successfully.
@miq-bot add_label smartstate |
@jerryk55 Cannot apply the following label because they are not recognized: smartstate |
Previously this could call join on a nil. Now that ruby 2.5 logs exceptions raised in threads by default we don't have to worry about joining the thread to re-raise. Instead we can just kill the thread if it's aborting and restart it if it is exited (cleanly or not).
752e2d6
to
8399786
Compare
Checked commits carbonin/manageiq@5a1eb86~...8399786 with ruby 2.5.5, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 app/models/miq_smart_proxy_worker/runner.rb
|
|
||
# if the thread is dead, start a new one and kill it if it is aborting | ||
if [email protected]? | ||
@tid.kill if @tid.status == "aborting" |
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.
It's amazing how much easier this is to grok by splitting apart that conditional into two conditional checks.
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.
LGTM
The heartbeat worker thread and the main thread were competing
to define the
Workers::MiqDefaults
constant.The main thread calls heartbeat from
do_work_loop
which isunavoidable. So to solve the problem we just wait until the first
call to
do_work
to start the heartbeat worker.This allows the main thread to resolve the constant without contention
and the heartbeat worker still gets started before we process the
first queue message
Fixes #19813