Skip to content
Snippets Groups Projects
Commit 6f162cc1 authored by Adam Hegyi's avatar Adam Hegyi
Browse files

Fix stuck VSA consistency worker

This change fixes the stuck VSA consistency worker where the cursor
value for end_event_timestamp is null.

Changelog: fixed
EE: true
parent 6a333566
No related branches found
No related tags found
2 merge requests!123158Fix stuck VSA consistency worker,!119439Draft: Prevent file variable content expansion in downstream pipeline
......@@ -17,11 +17,13 @@ def cursor_for(mode, model)
end
def consistency_check_cursor_for(model)
return {} if self["last_consistency_check_#{model.issuable_model.table_name}_issuable_id"].nil?
{
:start_event_timestamp => self["last_consistency_check_#{model.issuable_model.table_name}_start_event_timestamp"],
:end_event_timestamp => self["last_consistency_check_#{model.issuable_model.table_name}_end_event_timestamp"],
model.issuable_id_column => self["last_consistency_check_#{model.issuable_model.table_name}_issuable_id"]
}.compact
}
end
def refresh_last_run(mode)
......
......@@ -114,8 +114,8 @@ def cursor_data(aggregation)
{
issues_stage_event_hash_id: aggregation.last_consistency_check_issues_stage_event_hash_id,
merge_requests_stage_event_hash_id: aggregation.last_consistency_check_merge_requests_stage_event_hash_id,
issues_cursor: aggregation.consistency_check_cursor_for(Analytics::CycleAnalytics::IssueStageEvent).compact,
merge_requests_cursor: aggregation.consistency_check_cursor_for(Analytics::CycleAnalytics::MergeRequestStageEvent).compact
issues_cursor: aggregation.consistency_check_cursor_for(Analytics::CycleAnalytics::IssueStageEvent),
merge_requests_cursor: aggregation.consistency_check_cursor_for(Analytics::CycleAnalytics::MergeRequestStageEvent)
}
end
end
......
......@@ -133,6 +133,26 @@
end
end
context 'when the end_event_timestamp is nil' do
it 'does not raise missing cursor value error' do
stub_licensed_features(cycle_analytics_for_groups: true)
create(:cycle_analytics_aggregation, {
last_consistency_check_updated_at: 30.minutes.ago,
last_consistency_check_issues_stage_event_hash_id: -1,
last_consistency_check_issues_start_event_timestamp: 1.year.ago,
last_consistency_check_issues_end_event_timestamp: nil, # we allow nil-s here
last_consistency_check_issues_issuable_id: -1,
last_consistency_check_merge_requests_stage_event_hash_id: -1,
last_consistency_check_merge_requests_start_event_timestamp: 1.year.ago,
last_consistency_check_merge_requests_end_event_timestamp: nil, # we allow nil-s here
last_consistency_check_merge_requests_issuable_id: -1
})
expect { worker.perform }.not_to raise_error
end
end
it 'invokes the consistency check service for merge requests' do
stub_licensed_features(cycle_analytics_for_groups: true)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment