Blind fix of note update

What does this MR do and why?

Fix intermittent bug where work item updates overwrite user edits

What does this MR do and why?

This MR addresses an intermittent bug where user edits to work item notes were occasionally being overwritten by stale data. The issue was occurring rarely and could not be reliably reproduced locally or in production.

Problem

When a user was editing a note, the work item update subscription would sometimes return the old value, overwriting the new value that the user had just entered. This resulted in requiring page refresh to see new data.

Root Cause Hypothesis

The hypothesis is that the GraphQL subscription for note updates was reading from a database replica that had not yet been updated with the latest changes, causing it to return stale data.

Solution

This MR forces the note update subscription to read from the primary database instead of potentially stale replicas. This is implemented by wrapping the subscription update in a LoadBalancing::SessionMap block that ensures we're reading from the primary.

Implementation Details

The fix adds a private update method to the Subscriptions::Notes::Updated class that:

  1. Uses ::Gitlab::Database::LoadBalancing::SessionMap.current to force reading from the primary database
  2. Calls object.reset to ensure we're getting fresh data
  3. Returns the refreshed object

Important Note

This is a blind fix based on the symptoms observed and the hypothesis about replica lag. Since the bug cannot be reliably reproduced, we cannot definitively verify this solution. The approach is to:

  1. Deploy this fix
  2. Monitor for any new reports of the issue
  3. If the issue persists, we can revert this change and investigate alternative solutions

References

#535280 (closed)

Screenshots or screen recordings

Before After

How to set up and validate locally

Edit an existing note and see subscription returning new value.

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.

Edited by Gosia Ksionek

Merge request reports

Loading