Skip to content

Fix iteration reports with cadence rollover

What does this MR do and why?

The issues assigned to an expired iteration can be automatically re-assigned to the current iteration. This is the "rollover" feature.

The actual rollover is handled in RollOverIssuesService. When the rollover happens, the created resource events have the same timestamp. We set the event's created_at here: https://gitlab.com/gitlab-org/gitlab/blob/a71a70a0b48c60780141ff8a1323896c0a1a5842/ee/app/services/iterations/roll_over_issues_service.rb#L48 and then do a bulk insert.

For example, these events (resource_iteration_events records) could be generated during a rollover with the same created_at timestamp:

  • Issue 1 is removed from the expired iteration
  • Issue 1 is added to the current iteration

Note that both event records have the same created_at and this is problematic because another service TimeboxReportService relies on an assumption that a removal event is followed by an addition event (it is a reasonable assumption.)

For example, when we query SELECT * FROM resource_iteration_events ORDER BY created_at, the ties would be broken arbitrarily and an addition event could precede a removal event.

In this MR, we additionally use id column to correctly break ties for events records in TimeboxReportService.

Related to #363703 (closed)

Database Review

We want to order the rows additionally by id. As expected, this should not degrade the performance of the existing queries.

The sample query is for retrieving the events needed to calculate the burn chart data in https://gitlab.com/groups/gitlab-org/-/milestones/62.

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 euko

Merge request reports