Handle leftover temporary state in repo from before transaction
Gitaly won't be leaving temporary state behind in repositories with transactions. All of the temporary files related to crashes, such as a stale locks and temporary pack files, are going to be removed with the snapshot of the failed transaction.
When we enable transactions, there may be temporary state left over in the repository from before transactions. We should handle these in some way.
These could be handled via a migration as described here or proper WAL migration support (#5758 (closed)). That would be the best approach so we don't have to add special support for the housekeeping tasks that remove the trash as we won't be producing them anymore.
The idea is to remove everything from the repositories that is not explicitly expected to exist there. Preliminary list of files and directories to keep. The impact needs to be validated before creating the migration.
config-
.gitaly-full-repack-timestamp- Still needed, should likely be moved to the DB later.
-
gitaly-language.stats- Keep, unless rework removes the need
-
custom_hooks- Keep the directory and all its contents if non-empty
HEAD-
refs- Remove all
.lockfiles. - Keep all other files.
- Any remaining garbage will be removed through the reftable migration.
- Remove all
packed-refs-
reftable- Keep everything. Shouldn't contain garbage as only existed with transactions.
-
objects/info- Keep this present until we migrate away from
alternatesfiles.
- Keep this present until we migrate away from
objects/info/alternates-
objects/info/commit-graph, keep for now as per #5737 (comment 2513721475) -
objects/info/commit-graphs- Keep with suffixes:
.graph
- Keep with suffixes:
objects/info/commit-graphs/commit-graph-chain- (
objects/<xx>)- We could have the migration pack up loose objects. Then we don't need to keep these directories either.
-
objects/packmulti-pack-index- Keep everything with suffixes
.pack.idx.rev.bitmap
Everything will be removed that is not in the list above. For clarity, some specific removals include:
-
descriptionas it's unneeded on Gitaly -
infodirectory and all its contents are unneeded on Gitaly. -
hooks. Sample hooks scripts, unneeded by Gitaly. -
objects/info/commit-graphLegacy commit graphs. These would be old as we produce commit graph chains these days.
-
objects/pack-
.mtimesas transactions prune all unreachable objects -
.keepas we haven't used them explicitly.
-
-
logsas we don't store reflogs. -
worktrees,gitlab-worktreeas worktrees will land in the snapshot and don't need to be persisted.