Skip to content

git: Upgrade Git to correctly sync packed-refs to disk

Patrick Steinhardt requested to merge pks-git-corruption-sync-packed-refs into master

At GitLab we have recently received a report where a repository was left with a corrupted packed-refs file after the node hard-crashed even though core.fsync=reference was set. This is something that in theory should not happen if we correctly did the atomic-rename dance. So even if we crash in the middle of writing the packed-refs file we should only ever see either the old or the new state of the file.

And while we do the dance when writing the packed-refs file, there is indeed one gotcha: we use a FILE * stream to write the temporary file, but don't flush it before synchronizing it to disk. As a consequence any data that is still buffered will not get synchronized and a crash of the machine may cause corruption.

We have upstreamed a fix into Git v2.39.0 and backported that fix to Git v2.38.3.gl2. So let's upgrade our Git version to fix this bug.

Changelog: fixed

Closes #4707 (closed).

Merge request reports