-
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
Add reindex to job scheduler #16929
Add reindex to job scheduler #16929
Conversation
app/models/vmdb_metric.rb
Outdated
@@ -31,4 +32,9 @@ def self.rollup_metrics(resource, _interval_name, rollup_date) | |||
# Create new daily record... | |||
metric.update_attributes(:rows => rows, :size => size, :wasted_bytes => wasted_bytes, :percent_bloat => percent_bloat) | |||
end | |||
|
|||
def self.reindex_table_name | |||
"metrics_#{DateTime.now.utc.hour}" |
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.
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 think it's the next hour.
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.
Also I think this should be on Metric
not VmdbMetric
class_methods do | ||
def reindex | ||
_log.info("Reindexing table #{reindex_table_name}") | ||
result = ActiveRecord::Base.connection.execute("REINDEX TABLE #{reindex_table_name}") |
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.
We can use the methods defined here for this.
@@ -143,6 +143,12 @@ def metric_purge_all_timer | |||
end | |||
end | |||
|
|||
def database_maintenance_reindex_timer | |||
%w(VmdbMetric MiqQueue MiqWorker).each do |class_name| |
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 wonder if it would be easier to keep this list in a setting then have the class implement just the reindex_table
method.
Then we could just add the .reindex
method here and avoid the mixin entirely.
What do you think?
4893d5b
to
3958e37
Compare
This schedules reindex on VmdbMetric, MiqQueue, MiqWorker on an hourly schedule
3958e37
to
3da7e63
Compare
Checked commit jntullo@3da7e63 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 |
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.
This looks great! 💯
@jntullo Please add BZ link. |
@jntullo Backport of a few other PRs is blocked until this PR gets into gaprindashvili... Please create a BZ if it doesn't exist, and link other related PRs to the BZ as well. Thanks! |
Add reindex to job scheduler (cherry picked from commit da512b2) https://bugzilla.redhat.com/show_bug.cgi?id=1553795
Gaprindashvili backport details:
|
https://bugzilla.redhat.com/show_bug.cgi?id=1571246 Fixes: translation missing: en.advanced_settings.db_maintenance in Advanced Settings menu of the appliance console. The DB maintenance menu was removed in: ManageIQ#32 It was replaced with: ManageIQ/manageiq#16929 ManageIQ/manageiq#16940
This adds a reindex of
Metric
,MiqQueue
,MiqWorker
to run hourly via the job scheduler. At present, this is configured on the appliance console and done via cron jobs on the database appliance.Will be following up with scheduling of vacuum on tables.
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1553772
@miq-bot add_label wip
@miq-bot assign @carbonin