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

MiqQueue - remove MiqWorker lookup #14620

Merged
merged 3 commits into from
Apr 5, 2017
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
8 changes: 2 additions & 6 deletions app/models/miq_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,8 @@ def self.get(options = {})
msgs.each do |msg|
begin
_log.info("#{MiqQueue.format_short_log_msg(msg)} previously timed out, retrying...") if msg.state == STATE_TIMEOUT
w = MiqWorker.server_scope.find_by(:pid => Process.pid)
if w.nil?
msg.update_attributes!(:state => STATE_DEQUEUE, :handler => MiqServer.my_server)
else
msg.update_attributes!(:state => STATE_DEQUEUE, :handler => w)
end
handler = MiqWorker.my_worker || MiqServer.my_server
msg.update_attributes!(:state => STATE_DEQUEUE, :handler => handler)
result = msg
break
rescue ActiveRecord::StaleObjectError
Expand Down
2 changes: 2 additions & 0 deletions app/models/miq_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ def self.start_worker(*params)
w
end

cache_with_timeout(:my_worker) { server_scope.find_by(:pid => Process.pid) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbrock what happens with subclasses that call my_worker? MiqGenericWorker.my_worker as an example. Is it sharing a class variable or is it not shared?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be weird if we're in a priority worker process and MiqGenericWorker.my_worker returned a MiqPriorityWorker row.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok, but it's kinda weird if subclasses can return rows of not of it's type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will multiple workers run on the same pid?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kbrock no, I guess what I'm saying is it doesn't really make sense at the subclass level. We only want this on MiqWorker and not be inherited. I'm fine with it, just curious. I wasn't sure if you tried it out.


def self.find_all_current(server_id = nil)
MiqWorker.find_current(server_id)
end
Expand Down