Clean up old MR versions keep around refs
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Background
As of this writing (2022-11-17), we are keeping keep-around refs for each MR diff version (via MergeRequestDiff#keep_around_commits
). We do this to ensure that diff notes and commits that are dangling after a rebase/force-push will still be viewable (gitlab-foss#13524 (closed)).
Having these keep-around refs increases the number of refs in repositories and affects Git performance.
Proposal
Clean up old (need to determine the threshold for this) MR versions' keep-around refs. We need to ensure that displaying diff notes will degrade gracefully instead of erroring out. Commits that aren't kept around will return a 404 response.
One idea shared by @pks-t is to create revisions of an MR in refs/merge-requests/v$revision
instead of as a keep-around ref. This allows to clearly scope revisions to MRs and potentially cleanup of those refs at a later point.