Skip to content

Fix HllRedisCounter overwriting know events aggregation with symbol instead of string

What does this MR do and why?

Resolves: #414253 (closed)

HllRedicsCounter caches known events at class level, that mean that overwritten attribute persists between multiple metrics. Because symbols were used to overwrite aggregation attribute to weekly, and it was persisted later on in aggregated metrics calculation some events had aggregation configured with symbols and other string, causing events.all? { |event| event[:aggregation] == aggregation } to return false and raise error

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

To reproduce bug checkout master branch on commit 575966ef

data = Gitlab::Usage::ServicePingReport.for(output: :non_sql_metrics_values)

You should see error

Gitlab::UsageDataCounters::HLLRedisCounter::AggregationMismatch: [{"name"=>"g_project_management_epic_created", "aggregation"=>:weekly}, {"name"=>"project_management_users_unchecking_epic_task", "aggregation"=>"daily"}, {"name"=>"project_management_users_checking_epic_task", "aggregation"=>"daily"}, {"name"=>"g_project_management_users_updating_epic_titles", "aggregation"=>:weekly}, {"name"=>"g_project_management_users_updating_epic_descriptions", "aggregation"=>:weekly}, {"name"=>"g_project_management_users_creating_epic_notes", "aggregation"=>:weekly}, {"name"=>"g_project_management_users_updating_epic_notes", "aggregation"=>:weekly}, {"name"=>"g_project_management_users_destroying_epic_notes", "aggregation"=>:weekly}, {"name"=>"g_project_management_users_awarding_epic_emoji", "aggregation"=>"daily"}, {"name"=>"g_project_management_users_removing_epic_emoji", "aggregation"=>"daily"}, {"name"=>"g_project_management_users_setting_epic_start_date_as_fixed", "aggregation"=>:weekly}, {"name"=>"g_project_management_users_updating_fixed_epic_start_date", "aggregation"=>"daily"}, {"name"=>"g_project_management_users_setting_epic_start_date_as_inherited", "aggregation"=>:weekly}, {"name"=>"g_project_management_users_setting_epic_due_date_as_fixed", "aggregation"=>"daily"}, {"name"=>"g_project_management_users_updating_fixed_epic_due_date", "aggregation"=>"daily"}, {"name"=>"g_project_management_users_setting_epic_due_date_as_inherited", "aggregation"=>"daily"}, {"name"=>"g_project_management_epic_issue_added", "aggregation"=>:weekly}, {"name"=>"g_project_management_epic_issue_removed", "aggregation"=>"daily"}, {"name"=>"g_project_management_epic_issue_moved_from_project", "aggregation"=>"daily"}, {"name"=>"g_project_management_users_updating_epic_parent", "aggregation"=>"daily"}, {"name"=>"g_project_management_epic_closed", "aggregation"=>:weekly}, {"name"=>"g_project_management_epic_reopened", "aggregation"=>:weekly}, {"name"=>"g_project_management_issue_promoted_to_epic", "aggregation"=>"daily"}, {"name"=>"g_project_management_users_setting_epic_confidential", "aggregation"=>:weekly}, {"name"=>"g_project_management_users_setting_epic_visible", "aggregation"=>:weekly}, {"name"=>"g_project_management_epic_users_changing_labels", "aggregation"=>:weekly}, {"name"=>"g_project_management_epic_destroyed", "aggregation"=>"daily"}, {"name"=>"g_project_management_epic_cross_referenced", "aggregation"=>"daily"}, {"name"=>"g_project_management_users_epic_issue_added_from_epic", "aggregation"=>"daily"}, {"name"=>"g_project_management_epic_related_added", "aggregation"=>"daily"}, {"name"=>"g_project_management_epic_related_removed", "aggregation"=>"daily"}, {"name"=>"g_project_management_epic_blocking_added", "aggregation"=>"daily"}, {"name"=>"g_project_management_epic_blocking_removed", "aggregation"=>"daily"}, {"name"=>"g_project_management_epic_blocked_added", "aggregation"=>"daily"}, {"name"=>"g_project_management_epic_blocked_removed", "aggregation"=>"daily"}]
from /Users/mikolajwawrzyniak/gitlab/gitlab-development-kit/gitlab/lib/gitlab/usage_data_counters/hll_redis_counter.rb:82:in `block in calculate_events_union'

To check the fix in this MR checkoutmwaw/fix_redis_hll_metrics_type_mismatch_error branch, and repeat steps, see that there is no error.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mikołaj Wawrzyniak

Merge request reports