Increase ref cache trust TTL

What does this MR do and why?

Contributes to https://gitlab.com/gitlab-org/gitlab/-/work_items/627425

Problem

Metrics show that the majority of cases for a cache rebuild are due to trust key expirations: https://dashboards.gitlab.net/goto/afx4lhovbnbb4f?orgId=1

Screenshot_2026-09-03_at_11.36.49

☝️ Approximately 98% of tag caches and 90% of branch caches are recreated due to trust key expiration. ☝️

The previous value of 1 hour was chosen arbitrarily and intentionally quite low to self-heal quicker if something goes wrong.

The new cache has been operational on GitLab.com for several months, and it should be safe to increase the trust duration to benefit from cache hits.

Solution

  • Add a project-scoped flag for a six-hour trust TTL with up to 30 minutes of jitter.
  • Apply the selected TTL to both direct Redis and Lua trust writers.
  • Cover enabled and disabled behavior for empty and non-empty caches.

References

How to set up and validate locally

  1. The increase_ref_cache_trust_ttl flag is default-disabled and scoped to projects.
  2. With the flag disabled, verify the existing one-hour trust TTL and no jitter.
  3. Enable the flag for a project and verify the six-hour TTL with up to 30 minutes of jitter.
  4. Run the focused RSpec spec. Verification completed with 173 examples, with no RuboCop offenses. The feature flag definition also loads successfully.
Edited by Vasilii Iakliushin

Merge request reports

Loading
Loading