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

  1. In rails console enable the feature flag
    Feature.enable(:merge_requests_merge_data_simple_reads)
    
  2. Open any merge request
  3. Monitor the logs by doing something like tail -f log/application_json.log | grep -E "Missing MergeData record|MergeData mismatch detected
  4. Ensure MergeRequests::MergeData doesn't exist for the merge_request by executing MergeRequests::MergeData.destroy_all via console. You might also want to turn off merge_requests_merge_data_dual_write FF if you have that enabled.
  5. It should create a MergeRequests::MergeData shortly.
  6. Monitor the logs by doing something like tail -f log/application_json.log | grep -E "Missing MergeData record|MergeData mismatch detected
  7. Verify that the MergeRequests::MergeData gets created and matches MergeRequest attributes
  8. Adjust one of MergeRequests::MergeData value to a different value to MergeRequest by doing something like merge_data.update_columns(:merge_error, 'some error') via console.
  9. Refresh the merge request page
  10. Watch MergeData mismatch detected is logged and MergeRequests::MergeData matches the MergeRequest again.

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

Merge request reports

Loading