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:
- Uses
::Gitlab::Database::LoadBalancing::SessionMap.currentto force reading from the primary database - Calls
object.resetto ensure we're getting fresh data - 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:
- Deploy this fix
- Monitor for any new reports of the issue
- If the issue persists, we can revert this change and investigate alternative solutions
References
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.