diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-06-15 08:37:21 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2023-06-16 14:44:43 +0300 |
commit | db79f9379d8378b566ac3dbc78bddd15572fe7e5 (patch) | |
tree | b5cd0057ac7edf05e0d00a361783b1435ef9f714 | |
parent | 1ff92bd6545ee941bce1a2cafe2c8b6ef5ad8f9f (diff) |
git/housekeeping: Prune stale multi-pack-index locks
We have recently heard of a customer for whom repository housekeeping
stopped working: even though `OptimizeRepository()` is running, it
always returns an error when repacking objects.
As it turns out, the root cause of this is that there was a stale
multi-pack-index lock that makes Git fail. Amend our housekeeping logic
to prune such stale locks so that Gitaly can eventually recover without
the help of an administrator.
Changelog: fixed
-rw-r--r-- | internal/git/housekeeping/clean_stale_data.go | 1 | ||||
-rw-r--r-- | internal/git/housekeeping/clean_stale_data_test.go | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/internal/git/housekeeping/clean_stale_data.go b/internal/git/housekeeping/clean_stale_data.go index a21b4367e..89eb30506 100644 --- a/internal/git/housekeeping/clean_stale_data.go +++ b/internal/git/housekeeping/clean_stale_data.go @@ -39,6 +39,7 @@ var lockfiles = []string{ "info/attributes.lock", "objects/info/alternates.lock", "objects/info/commit-graphs/commit-graph-chain.lock", + "objects/pack/multi-pack-index.lock", } type ( diff --git a/internal/git/housekeeping/clean_stale_data_test.go b/internal/git/housekeeping/clean_stale_data_test.go index 52f5327be..fcc655922 100644 --- a/internal/git/housekeeping/clean_stale_data_test.go +++ b/internal/git/housekeeping/clean_stale_data_test.go @@ -743,6 +743,17 @@ func TestRepositoryManager_CleanStaleData_withSpecificFile(t *testing.T) { packedRefsNew: 1, }, }, + { + desc: "multi-pack index", + file: "multi-pack-index.lock", + subdirs: []string{ + "objects", "pack", + }, + finder: findStaleLockfiles, + expectedMetrics: cleanStaleDataMetrics{ + locks: 1, + }, + }, } { tc := tc |