Skip to content

Update cached counts when issue is promoted

Jan Provaznik requested to merge jp-double-save-cache into master

What does this MR do and why?

When promoting an issue to epic, old issue's state is changed to "closed", because state was changed cache update should be scheduled in after_commit hook.

But during promotion there is one big transaction inside which "save" is called multiple times on the old (issue) entity. First to close the issue, then later to mark it as promoted => this causes that state_id_previously_changed? is false after second save as it checks only last save changes (so in after_commit callback too).

To avoid scenarios like this, this MR updates the code a bit:

  • adds a new module which models can use to "register" an epic for update (so these are used in after_save or before destroy)
  • then in after_commit schedules cache update for "registered" ids

Related to #378907 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jan Provaznik

Merge request reports