Log how many records repository cleanup removes
What does this MR do and why?
Repository cleanup deletes the merge request diffs and note diff files that reference rewritten commits, but the job log does not say how many it removed. This MR counts them in Projects::CleanupService (stats) and adds them to the RepositoryCleanupWorker job log as merge_request_diffs_deleted and note_diff_files_deleted, so the size of a cleanup can be seen in the logs. The counts are logged whether or not the bound_repository_cleanup_transactions feature flag is enabled.
It was split out of Bound database transactions of repository cleanup (!265959 - merged) so that the fix there can merge without the logging. This MR targets that MR's branch, so its diff only shows the logging change until that MR merges.
Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/634218+
Log fields
The counts are worker-specific, so they use log_extra_metadata_on_done, which writes them under json.extra.repository_cleanup_worker. I checked the fields in Labkit::Fields (gitlab-labkit 5.8.0). They are common fields such as user, project, pipeline and HTTP fields, and none of them describes a count of removed records, so there is no field to reuse.
Database queries
This MR runs no new queries. It only counts the rows that the existing destroy_all and delete_all calls already return.
Screenshots or screen recordings
Not applicable, there is no UI change.
How to set up and validate locally
- Upload a BFG object map in the repository settings of a project with merge requests that reference the rewritten commits.
- Check that the
RepositoryCleanupWorkerjob log includesmerge_request_diffs_deletedandnote_diff_files_deleted.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.