Draft: Check repository cache after block yield

Why

Gitlab::RepositorySetCache#fetch can have a race condition which can result in stale reads due to slow block yields to fetch. See #506430 for full details

What

Check repository cache after block yield

Since competing concurrent processes could encounter an empty cache, they might both race to write on fetch. If the first process's block is slow, it could overwrite a subsequent cache resulting in stale data. This make sure that given multiple fetches only the first to finish writes to the cache.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Related to #506430

Edited by Hunter Stewart

Merge request reports

Loading