Skip to content

WorkItems: Update Rolledup dates when new child is created

What does this MR do and why?

WorkItems: Update Rolledup dates when new child is created

As part of the epic, we need to ensure that when a new WorkItem is created, in a WorkItem hierarchy we update all the parent WorkItems in that hierarchy with rolledup dates to use the most broad start/due dates in its hierarchy.

This is the first MR to introduce events that might trigger the dates rolledup updates. When this is approved, I'll add a followup for the other events that will trigger the same update, like:

  • when child start/due dates change
  • when a milestone start/due date is changed
  • when a child milestone change
  • etc

This is using the same Database update strategy used by the current Epic inheritable dates implementation. But instead of calling the worker directly on the events that trigger the hierarchy update, I decided to use the GitLab EventStore to use a events-based approach. This way, these events can also be used to other workers. I think this is important as we're planning to also have rolledup weights, and other widgets that will require a similar hierarchy update.

This is being developed behind the feature flag: work_items_rolledup_dates

Related to: #434835 (closed)

Changelog: added EE: true

New Queries

WorkItems::DatesSource.by_work_item_id
Statistics:

Time: 0.796 ms
  - planning: 0.758 ms
  - execution: 0.038 ms
    - I/O read: 0.000 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 0 from the buffer pool
  - reads: 0 from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0

Query locks:

  RELKIND | RELNAMESPACE |                        RELNAME                         |   BELONGS TO RELATION   | LOCKTYPE |      MODE       | GRANTED | FASTPATH  
----------+--------------+--------------------------------------------------------+-------------------------+----------+-----------------+---------+-----------
  r       | public       | work_item_dates_sources                                | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | wi_datessources_due_date_sourcing_work_item_id_index   | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | wi_datessources_start_date_sourcing_milestone_id_index | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | wi_datessources_due_date_sourcing_milestone_id_index   | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | wi_datessources_namespace_id_index                     | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | work_item_dates_sources_pkey                           | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | wi_datessources_start_date_sourcing_work_item_id_index | work_item_dates_sources | relation | AccessShareLock | true    | true      
WorkItems::DatesSource.rolledup
Statistics:

Time: 0.736 ms
  - planning: 0.687 ms
  - execution: 0.049 ms
    - I/O read: 0.000 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 0 from the buffer pool
  - reads: 0 from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0

Query locks:

  RELKIND | RELNAMESPACE |                        RELNAME                         |   BELONGS TO RELATION   | LOCKTYPE |      MODE       | GRANTED | FASTPATH  
----------+--------------+--------------------------------------------------------+-------------------------+----------+-----------------+---------+-----------
  r       | public       | work_item_dates_sources                                | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | wi_datessources_due_date_sourcing_work_item_id_index   | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | wi_datessources_start_date_sourcing_milestone_id_index | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | wi_datessources_due_date_sourcing_milestone_id_index   | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | wi_datessources_namespace_id_index                     | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | work_item_dates_sources_pkey                           | work_item_dates_sources | relation | AccessShareLock | true    | true      
  i       | public       | wi_datessources_start_date_sourcing_work_item_id_index | work_item_dates_sources | relation | AccessShareLock | true    | true      
WorkItems::Widgets::RolledupDatesService::HierarchyUpdateService#update_all
Statistics:

Time: 0.751 ms
  - planning: 0.699 ms
  - execution: 0.052 ms
    - I/O read: 0.000 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 0 from the buffer pool
  - reads: 0 from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0

Query locks:

  RELKIND | RELNAMESPACE |                        RELNAME                         |   BELONGS TO RELATION   | LOCKTYPE |       MODE       | GRANTED | FASTPATH  
----------+--------------+--------------------------------------------------------+-------------------------+----------+------------------+---------+-----------
  r       | public       | work_item_dates_sources                                | work_item_dates_sources | relation | RowExclusiveLock | true    | true      
  i       | public       | wi_datessources_due_date_sourcing_work_item_id_index   | work_item_dates_sources | relation | RowExclusiveLock | true    | true      
  i       | public       | wi_datessources_start_date_sourcing_milestone_id_index | work_item_dates_sources | relation | RowExclusiveLock | true    | true      
  i       | public       | wi_datessources_due_date_sourcing_milestone_id_index   | work_item_dates_sources | relation | RowExclusiveLock | true    | true      
  i       | public       | wi_datessources_namespace_id_index                     | work_item_dates_sources | relation | RowExclusiveLock | true    | true      
  i       | public       | work_item_dates_sources_pkey                           | work_item_dates_sources | relation | RowExclusiveLock | true    | true      
  i       | public       | wi_datessources_start_date_sourcing_work_item_id_index | work_item_dates_sources | relation | RowExclusiveLock | true    | true      

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

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

Before After

How to set up and validate locally

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

Edited by Kassio Borges

Merge request reports