Add wrapper to read merge_data attributes from merge_data
What does this MR do and why?
This MR implements a away to monitor the synced merge_data attributes during simple read actions for all related attributes.
The key changes include:
- Added a module that watches for differences between data stored in two places (the old location and new location) and logs warnings when they don't match
- When mismatches are detected, the system automatically queues a background job to fix the inconsistency by copying the correct data to the new location. It should be unlikely as we have dual write procedures as well as backfill. This is just an additional layer to catch any unexpected cases.
- Some refactoring to minimize repetition
References
#560938
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
- In rails console enable the feature flag
Feature.enable(:merge_requests_merge_data_simple_reads) - Open any merge request
- Monitor the logs by doing something like
tail -f log/application_json.log | grep -E "Missing MergeData record|MergeData mismatch detected - Ensure
MergeRequests::MergeDatadoesn't exist for the merge_request by executingMergeRequests::MergeData.destroy_allvia console. You might also want to turn offmerge_requests_merge_data_dual_writeFF if you have that enabled. - It should create a
MergeRequests::MergeDatashortly. - Monitor the logs by doing something like
tail -f log/application_json.log | grep -E "Missing MergeData record|MergeData mismatch detected - Verify that the
MergeRequests::MergeDatagets created and matchesMergeRequestattributes - Adjust one of
MergeRequests::MergeDatavalue to a different value toMergeRequestby doing something likemerge_data.update_columns(:merge_error, 'some error')via console. - Refresh the merge request page
- Watch
MergeData mismatch detectedis logged andMergeRequests::MergeDatamatches theMergeRequestagain.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #560938
Edited by Sincheol (David) Kim