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

Memoize cols_on_metric_rollup in chargeback #17927

Merged
merged 2 commits into from
Sep 10, 2018

Conversation

lpichler
Copy link
Contributor

Pulled out from #17591 done during work on this #17592

Links

*#17592

@miq-bot add_label performance, chargeback

@miq-bot assign @gtanzillo

@miq-bot
Copy link
Member

miq-bot commented Aug 30, 2018

Checked commits lpichler/manageiq@bf2b318~...131cf41 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 👍

chargeable_cols.map! { |x| VIRTUAL_COL_USES[x] || x }.sort
@chargeable_cols_on_metric_rollup ||= begin
existing_cols = MetricRollup.attribute_names
chargeable_cols = pluck(:metric) & existing_cols
Copy link
Member

Choose a reason for hiding this comment

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

Could new records be created with new data in the metric column that would never be seen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes but not during running application. It could be added only by adding record (this happens very rarely) to chargeable_field.yml and based on the yaml, table chargeable_field table is filled up in the seed process.

thanks

@lpichler lpichler closed this Aug 30, 2018
@lpichler lpichler reopened this Aug 30, 2018
@gtanzillo gtanzillo added this to the Sprint 94 Ending Sept 10, 2018 milestone Sep 10, 2018
@gtanzillo gtanzillo merged commit 345a318 into ManageIQ:master Sep 10, 2018
@lpichler lpichler deleted the memoize_cols_on_metric_rollup branch September 11, 2018 07:03
agrare added a commit to agrare/manageiq that referenced this pull request Sep 12, 2018
…on_metric_rollup"

This reverts commit 345a318, reversing
changes made to ac675f5.
gtanzillo added a commit that referenced this pull request Sep 12, 2018
…ollup

Revert "Merge pull request #17927 from lpichler/memoize_cols_on_metri…
chargeable_cols.map! { |x| VIRTUAL_COL_USES[x] || x }.sort
@chargeable_cols_on_metric_rollup ||= begin
existing_cols = MetricRollup.attribute_names
chargeable_cols = pluck(:metric) & existing_cols
Copy link
Member

Choose a reason for hiding this comment

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

@libor, I think this line may be causing the sporadic test failures. If this code is called before ChargeableField is seeded it will memoize an empty array. The other tests will use the memoized value and potentially get the nil error. I found that consumption_with_rollups_spec.rb calls this code in a bunch of places without seeding ChargeableField. The fix may be to just make sure the class is seeded first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes! and finally I probably found a culprit. ./spec/models/chargeback/consumption_with_rollups_spec.rb but I am not sure it if it is the only culprit.

thanks

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