Skip to content

repos: Remove use of advisory lock

Administrator requested to merge sync-repo-singleflight into main

Created by: ryanslade

Repo syncing can only happen in repo-updater, of which we only ever run one instance. We can avoid using advisory locks by instead using the singleflight package to ensure that only one sync per repo can happen concurrently.

As part of the change syncRepo now always blocks and it is up to SyncRepo to decide whether to spawn a goroutine or not.

This change was motivated by performance issues on sourcegraph.com where we observed repo-updater blocking for up to three minutes waiting on advisory locks which would in turn starve it of database connections.

Part of https://github.com/sourcegraph/sourcegraph/issues/25153

Merge request reports

Loading