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

  1. Enable on staging
  2. Monitor for any increase in missing keep-around refs or related errors
  3. Enable on a percentage of production projects
  4. Enable globally
  5. Remove feature flag

Feature flag

  • Name: async_keep_around_refs_for_merge_request_diffs
  • Type: ops
  • Default: disabled
  • Introduced in: !223665 (merged)
Assignee Loading
Time tracking Loading