Feature flag rollout: async_keep_around_refs_for_merge_request_diffs
Summary
This issue tracks the rollout of the async_keep_around_refs_for_merge_request_diffs feature flag.
When enabled, this flag moves the keep_around_commits Gitaly RPC call for MergeRequestDiff records from a synchronous after_create_commit callback to an asynchronous Sidekiq worker (MergeRequests::KeepAroundRefsWorker).
Problem
keep_around_commits performs Gitaly RPCs to write keep-around refs, preventing commit SHA garbage collection. When run synchronously in a callback, it holds database connections idle while waiting for I/O responses, contributing to idle-in-transaction time.
Solution
A new Sidekiq worker (MergeRequests::KeepAroundRefsWorker) with 20 retries and exponential backoff handles the keep-around ref creation asynchronously. Git GC has a default 2-week grace period before pruning dangling objects, giving ample time for retries (~18 days across 20 retries).
Rollout plan
- Enable on staging
- Monitor for any increase in missing keep-around refs or related errors
- Enable on a percentage of production projects
- Enable globally
- Remove feature flag
Feature flag
-
Name:
async_keep_around_refs_for_merge_request_diffs - Type: ops
- Default: disabled
- Introduced in: !223665 (merged)