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 consistency with purging #14676

Merged
merged 7 commits into from
Apr 10, 2017
Merged

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Apr 6, 2017

related to #14569

Bring consistency to Purging:

  • remove boilerplate
  • removing inconsistency (slowly)
  • moving all from put_unless_exists over to put.
  • put into the general queue
  • following patterns (which are already tuned for performance)

@kbrock kbrock requested review from jrafanie, Fryguy and lfu April 6, 2017 14:58
@chessbyte chessbyte changed the title Miq queue purge es MiqQueue purge EventStream Apr 6, 2017
@Fryguy Fryguy assigned Fryguy and unassigned gtanzillo Apr 6, 2017
@kbrock kbrock force-pushed the miq_queue_purge_es branch from 7cbd421 to 4e25b61 Compare April 6, 2017 19:32
@kbrock kbrock changed the title MiqQueue purge EventStream MiqQueue consistency with purging Apr 6, 2017
@kbrock kbrock force-pushed the miq_queue_purge_es branch 2 times, most recently from 5799585 to 4aa5eaf Compare April 6, 2017 20:08
# mode = value.number_with_method? ? :date : :remaining
# value = value.to_i_with_method.seconds.ago.utc if mode == :date
# return mode, value
# end
Copy link
Member

Choose a reason for hiding this comment

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

This comment is confusing to me.

module PurgingMixin
extend ActiveSupport::Concern

module ClassMethods
# This provides backward support for date only implementations
# It is assumed most classes will override to provide `:remaining` support
Copy link
Member

Choose a reason for hiding this comment

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

If most classes will override, then why not make that the default and only do the rare places for override.

Even so, I think this comment is wrong, and I can't understand it. Everything supports by date, so why does it say "backward support for date only implementations". Nearly all of them are date only, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, just under half are mode and date (options: :remaining, :date)

@@ -35,15 +35,14 @@ def self.purge_realtime_timer(ts = nil)
purge_timer(ts, "realtime")
end

# NOTE: purge_#{interval} was introduced to make uniqueness easier
# now that we do not require unique purging, possibly go back to :args => [value, interval]
Copy link
Member

Choose a reason for hiding this comment

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

I feel like these NOTEs to yourself (as well as the others in this PR) would be better served if moved into a separate github issue.

kbrock added 7 commits April 7, 2017 08:44
following PurgingMixin framework

- removed limit support, and manually overriding window_size
- kept purge_date defaulting (to prevent oops and deleting everything)
converted put_or_update to put on general queue
queuing directly into purge_by_{mode}
- converted put_or_update to put on general queue
- queuing directly into purge_by_{mode}
- delete already defined purge_timer
- converted put_or_update to put on general queue
- queuing directly into purge_by_date
- converted put_or_update to put on general queue
- allow multiple inserts into the queue

NOTE: this is still not a typical purger
- converted put_or_update to put on general queue
- introduce purge_by_date concept (which is just naming)
NOTE: this is still not a typical purger
@kbrock kbrock force-pushed the miq_queue_purge_es branch from 4aa5eaf to ecb49ef Compare April 7, 2017 12:53
@miq-bot
Copy link
Member

miq-bot commented Apr 7, 2017

Checked commits kbrock/manageiq@d7a1e3a~...ecb49ef with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
13 files checked, 0 offenses detected
Everything looks good. 🏆

end

def purge_queue(mode, value)
MiqQueue.put(
Copy link
Member

Choose a reason for hiding this comment

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

@kbrock Role is not specified any more. Is it by intention?

Copy link
Member Author

Choose a reason for hiding this comment

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

Purging is quick. We perform it as pure sql and do not download tons of records.

So the thought is there is no reason to limit which workers can purge.
But that is my though, wanted your feedback here.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, purging is a pure database function and can be done anywhere

)
end
alias_method :purge_timer, :purge_queue

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, is the commit message wrong here?

- converted put_or_update to put on general queue
- queuing directly into purge_by_date

Are we now using the mixin's method which does a put? All I see is deleted lines here, no new method.

Copy link
Member

Choose a reason for hiding this comment

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

It's ok, it's coming from the mixin. It wasn't clear when looking at the commit message.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks for keeping me honest.

Yes, most of these come from the default implementation

@jrafanie
Copy link
Member

jrafanie commented Apr 7, 2017

This approach looks good to me. Is it possible to have generic tests that each of these classes can be tested with shared examples?

@Fryguy Fryguy merged commit 932ac57 into ManageIQ:master Apr 10, 2017
@Fryguy Fryguy added this to the Sprint 58 Ending Apr 10, 2017 milestone Apr 10, 2017
@Fryguy
Copy link
Member

Fryguy commented Apr 10, 2017

@kbrock Is this for fine?

@kbrock kbrock added the fine/no label Apr 10, 2017
@kbrock kbrock deleted the miq_queue_purge_es branch April 10, 2017 22:06
@zeari
Copy link

zeari commented Apr 12, 2017

@kbrock Is this for fine?

Any reason it shouldnt be in fine?
Its needed for:
https://bugzilla.redhat.com/show_bug.cgi?id=1428595
#14322

@kbrock kbrock added fine/yes and removed fine/no labels Apr 12, 2017
@kbrock
Copy link
Member Author

kbrock commented Apr 12, 2017

ok, fine/yes sounds fine

simaishi pushed a commit that referenced this pull request Apr 13, 2017
MiqQueue consistency with purging
(cherry picked from commit 932ac57)
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit 9283c5a8a75ac449970f05752790527a7c6f98b2
Author: Jason Frey <[email protected]>
Date:   Mon Apr 10 17:54:05 2017 -0400

    Merge pull request #14676 from kbrock/miq_queue_purge_es
    
    MiqQueue consistency with purging
    (cherry picked from commit 932ac5773fcefa6dae3bc1234d95241549147af1)

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.

8 participants