Skip to content

Remove dangling running entries from ci running builds table

What does this MR do and why?

Related to https://gitlab.com/gitlab-org/gitlab/-/issues/349195

With !77507 (merged) we fixed the bug that was leaving these records behind. This migration is expected to delete ~50k rows from the ci_running_builds table that belong to builds that are failed.

Migrations output

https://gitlab.com/gitlab-org/gitlab/-/jobs/2034478960

It's not possible to revert this migration automatically, but in case it goes wrong, the records can be recreated by running one of the appropriate following commands in a Rails console:

# replace `id` with the id of the job, e.q.: `42`  
Ci::Build.find(id).create_runtime_metadata!

# replace `ids` with an array of job ids, e.q.: `[42, 43]` 
Ci::Build.includes(:runner, :project).where(id: ids).each(&:create_runtime_metadata!)

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 Marius Bobin

Merge request reports