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

Move EmsRefresh targets to MiqQueue data #16271

Merged

Conversation

agrare
Copy link
Member

@agrare agrare commented Oct 23, 2017

Reduce the overhead of put_or_update by moving EmsRefresh targets from
MiqQueue args to data. Also replace uniquing the targets on put with
msg.args[0] | targets with just a simple concat and unique the targets
on the dequeue side.

@agrare agrare force-pushed the move_ems_refresh_targets_to_miq_queue_data branch 2 times, most recently from e286603 to b500ff9 Compare October 24, 2017 02:14
@@ -171,7 +171,7 @@ def self.queue_merge(targets, ems, create_task = false)

# Items will be naturally serialized since there is a dedicated worker.
MiqQueue.put_or_update(queue_options) do |msg, item|
targets = msg.nil? ? targets : (msg.args[0] | targets)
targets = msg.nil? ? targets : msg.data.concat(targets)
Copy link
Contributor

@Ladas Ladas Oct 24, 2017

Choose a reason for hiding this comment

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

gives undefined method `concat' for nil:NilClass (NoMethodError)

we need to do

(msg.data || []).concat(targets)

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm that's strange I didn't get this, what case did you hit that? That would have to be if the message existed but didn't get any targets assigned?

Copy link
Contributor

@Ladas Ladas Oct 24, 2017

Choose a reason for hiding this comment

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

this happens to me everytime that new MiqQueue record is created, the default data seems to be nil

https://github.com/Ladas/manageiq/blob/241d9ba616cb5c7beb1a9859fe045c093c3120e8/app/models/miq_queue.rb#L113

Copy link
Member

Choose a reason for hiding this comment

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

If you have a new MiqQueue record, then msg will be nil and you'll hit the first part of the ternary.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this happens when merging existing queue items where msg isn't nil but data hasn't been set, also can go away of we migrate existing queue items

Copy link
Contributor

Choose a reason for hiding this comment

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

Migration sounds like the best option 👍

@Ladas
Copy link
Contributor

Ladas commented Oct 24, 2017

@agrare changes I needed to do to have working refresh #16274 , take the commits here, or lets continue there :-) I'll be adding few more commits to fix logging and n+1 requests to EMS I am seeing.

(args are ok)

@Ladas
Copy link
Contributor

Ladas commented Oct 24, 2017

@agrare @Fryguy also the disadvantage of fetching the whole data to ruby is rising mem consumption, I see it takes around 800MB for 4k targets. So that will hit any worker that will be doing the queuing. (using DB concat, memory is flat)

unless msg.args[0].nil?
msg.data.concat(msg.args.shift)
msg.args = []
end
Copy link
Member Author

Choose a reason for hiding this comment

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

@Fryguy this works around merging targets into existing queue items that still had their targets in args, do you think this is needed?

@agrare agrare force-pushed the move_ems_refresh_targets_to_miq_queue_data branch from b044dd7 to a365926 Compare October 24, 2017 14:52
@agrare agrare force-pushed the move_ems_refresh_targets_to_miq_queue_data branch 3 times, most recently from e964b48 to 53e608b Compare October 24, 2017 15:39
Copy link
Member

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

:shipit:

if msg && msg.args[0]
msg.data.concat(msg.args.shift)
msg.args = []
end
Copy link
Member Author

Choose a reason for hiding this comment

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

@Fryguy made some changes so my comment was removed but same question here ^^ do you think this is needed? My worry is if we don't clear args then we'll get refresh delivered with EmsRefresh.refresh(args, data)

Copy link
Member

Choose a reason for hiding this comment

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

I'm ok with this for now, but ultimately, I don't think it's needed, or we should deal with it in a data migration. I don't like live "fixing" of data.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay I'll work on a data migration so we can get rid of this, agree we don't want to carry this forever

Copy link
Member Author

Choose a reason for hiding this comment

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

Can be removed once ManageIQ/manageiq-schema#107 is in

msg.args = []
end

targets = msg.nil? || msg.data.nil? ? targets : msg.data.concat(targets)
Copy link
Member Author

Choose a reason for hiding this comment

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

Same here, this can go back to msg.nil? ? targets : ... once we get ManageIQ/manageiq-schema#107 in

Reduce the overhead of put_or_update by moving EmsRefresh targets from
MiqQueue args to data.  Also replace uniquing the targets on put with
`msg.args[0] | targets` with just a simple concat and unique the targets
on the dequeue side.
@agrare agrare force-pushed the move_ems_refresh_targets_to_miq_queue_data branch from 53e608b to 3691157 Compare October 26, 2017 17:59
@agrare
Copy link
Member Author

agrare commented Oct 26, 2017

Okay with ManageIQ/manageiq-schema#107 merged I just dropped the last commit since all it did was handle migrating queue args.

@miq-bot
Copy link
Member

miq-bot commented Oct 26, 2017

Checked commit agrare@3691157 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0
4 files checked, 0 offenses detected
Everything looks fine. 🍪

@agrare
Copy link
Member Author

agrare commented Oct 27, 2017

@Fryguy can you take another look? Should be ready now.

@Fryguy Fryguy merged commit b1aa854 into ManageIQ:master Oct 30, 2017
@Fryguy Fryguy added this to the Sprint 72 Ending Oct 30, 2017 milestone Oct 30, 2017
@agrare agrare deleted the move_ems_refresh_targets_to_miq_queue_data branch January 16, 2018 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants