Stale cache when referenced issuable in merge request note changes its state
Summary
When merge_request_discussion_cache
feature flag is enabled and when a discussion on merge request references an issuable (Issue, Merge Request or Epic), and then the state of that issuable changes after the discussion has already been cached, subsequent requests will load a stale cache with outdated state.
It'll only invalidate when the cache expires.
Steps to reproduce
- Add a comment on MR with a reference to another issue, MR or epic.
- Reload the page so cache will created.
- Close the referenced issuable.
- Reload the MR page and you can see that the issuable is still referenced but as open instead of closed.
Example Project
Tested this locally but it can be recreated in https://gitlab.com/patrickbajao/verification since feature flag is enabled for this project.
What is the current bug behavior?
It shows outdated referenced issuable state.
What is the expected correct behavior?
It shows updated referenced issuable state.
Possible fixes
Include the sha of notes' redacted_note_html
(like Digest::SHA1.hexdigest(redacted_note_html)
) because we set this when we post process the content. We currently only add the sha of notes' id
in Discussion#cache_key
so we could probably combine them.