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

Add reindex to job scheduler #16929

Merged
merged 1 commit into from
Feb 2, 2018
Merged

Conversation

jntullo
Copy link

@jntullo jntullo commented Feb 1, 2018

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

@@ -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}"
Copy link
Author

Choose a reason for hiding this comment

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

@carbonin is this the appropriate class for this, and am I understanding it correctly that it should be performed on metrics_<hour_of_day>?

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 it's the next hour.

Copy link
Member

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}")
Copy link
Member

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|
Copy link
Member

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?

@jntullo jntullo force-pushed the db_maintenance branch 4 times, most recently from 4893d5b to 3958e37 Compare February 1, 2018 20:47
@jntullo jntullo changed the title [WIP] Add reindex to job scheduler Add reindex to job scheduler Feb 1, 2018
@miq-bot miq-bot removed the wip label Feb 1, 2018
This schedules reindex on VmdbMetric, MiqQueue, MiqWorker on an hourly schedule
@miq-bot
Copy link
Member

miq-bot commented Feb 2, 2018

Checked commit jntullo@3da7e63 with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0
5 files checked, 0 offenses detected
Everything looks fine. 👍

Copy link
Member

@carbonin carbonin left a comment

Choose a reason for hiding this comment

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

This looks great! 💯

@simaishi
Copy link
Contributor

simaishi commented Mar 7, 2018

@jntullo Please add BZ link.

@simaishi
Copy link
Contributor

simaishi commented Mar 8, 2018

@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!

@jntullo
Copy link
Author

jntullo commented Mar 9, 2018

simaishi pushed a commit that referenced this pull request Mar 9, 2018
@simaishi
Copy link
Contributor

simaishi commented Mar 9, 2018

Gaprindashvili backport details:

$ git log -1
commit f1c1203e5e8c70824b464f137183d52fb6544958
Author: Nick Carboni <[email protected]>
Date:   Fri Feb 2 09:26:13 2018 -0500

    Merge pull request #16929 from jntullo/db_maintenance
    
    Add reindex to job scheduler
    (cherry picked from commit da512b21dc63f23324e1d05a10ee3b00ef693d73)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1553795

jrafanie added a commit to jrafanie/manageiq-appliance_console that referenced this pull request Apr 24, 2018
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
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.

4 participants