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
Fixes #10439 - Made trends:reduce task idempotent #2379
Conversation
Am I missing something here? I only see tests, no change. |
@domcleal That's because my code is awesome :) I have added the tests, but they didn't fail. That means that I have already covered these use cases. |
Ok, so it's just adding tests and not actually making it idempotent. How is this intended to be used? It's unclear to me from the original ticket. |
@ShimShtein first, be careful, you are starting to sound like me. Next up you'll be using four letter words liberally, and I don't want to be a bad influence 😛 |
@domcleal Now in a more serious tone: |
Who runs the task? It isn't configured as a cronjob in our packages, called from a DB migration to my knowledge, or documented. Should be called regularly, or only during upgrade from 1.8 to 1.9? |
@@ -6,6 +6,7 @@ class TrendsTest < ActiveSupport::TestCase | |||
Rake.application.rake_require 'tasks/trends' | |||
Rake::Task.define_task(:environment) | |||
Rake::Task['trends:reduce'].reenable | |||
Rake::Task['trends:clean'].reenable |
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 thought we wanted to get rid of the clean task? is it needed anymore?
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'll put it in a different PR. Without this line the tests will fail.
Okay, I missed that. The issue description says it should be moved to migrations - should it? |
I think it make sense to keep it, in the scenario you still collect new trends counters while the migration is working, one can rerun the task to clear up any new data points. also useful in case you have multiple foreman running, and you upgrade them one by one or other non standard usage cases.. |
For simple scenarios it should run only once in the migration. But PR #2365 pointed out a use case when there is more than one writer to a single DB. |
Merged as c27e0f6, thanks @ShimShtein. |
Made sure that the task can run multiple times without damaging the system, and it knows how to deal with data points that were added after the original data has already migrated.