diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-10-18 11:23:35 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2022-10-18 11:23:35 +0300 |
commit | 38de5e1a289558d02e9bc356d426c266a724d9d7 (patch) | |
tree | 03823c355e16c3d25107471e687d82745061032a | |
parent | 4c0ffe389141ff3c20a78b16bc95a61d8903a56a (diff) |
housekeeping: Clean up stale alternates and gitattributes locks
We're using `transaction.CommitLockedFile()` to ensure atomic updates
with proper voting for both the alternates and gitattributes files. This
means that we set up a lockfile before committing the updated files to
disk. Naturally, it may happen that the lockfile never gets deleted if
Gitaly were to crash between creating and committing it. The consequence
is that any such stale lockfile may now obstruct all changes to the
target files.
We already cope with such stale locks for other filetypes, where we
delete them after a grace period of 15 minutes in our housekeeping
procedures. Extend this mechanism to also cover alternates and
gitattributes to ensure that we can automatically recover from above
situation.
Changelog: fixed
-rw-r--r-- | internal/git/housekeeping/clean_stale_data.go | 2 | ||||
-rw-r--r-- | internal/git/housekeeping/clean_stale_data_test.go | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/internal/git/housekeeping/clean_stale_data.go b/internal/git/housekeeping/clean_stale_data.go index a188f3fdd..424717e5d 100644 --- a/internal/git/housekeeping/clean_stale_data.go +++ b/internal/git/housekeeping/clean_stale_data.go @@ -34,6 +34,8 @@ const ( var lockfiles = []string{ "config.lock", "HEAD.lock", + "info/attributes.lock", + "objects/info/alternates.lock", "objects/info/commit-graphs/commit-graph-chain.lock", } diff --git a/internal/git/housekeeping/clean_stale_data_test.go b/internal/git/housekeeping/clean_stale_data_test.go index 8c7a62f4b..6c478786c 100644 --- a/internal/git/housekeeping/clean_stale_data_test.go +++ b/internal/git/housekeeping/clean_stale_data_test.go @@ -565,6 +565,28 @@ func TestRepositoryManager_CleanStaleData_withSpecificFile(t *testing.T) { }, }, { + desc: "locked attributes", + file: "attributes.lock", + subdirs: []string{ + "info", + }, + finder: findStaleLockfiles, + expectedMetrics: cleanStaleDataMetrics{ + locks: 1, + }, + }, + { + desc: "locked alternates", + file: "alternates.lock", + subdirs: []string{ + "objects", "info", + }, + finder: findStaleLockfiles, + expectedMetrics: cleanStaleDataMetrics{ + locks: 1, + }, + }, + { desc: "locked commit-graph-chain", file: "commit-graph-chain.lock", subdirs: []string{ |