This is about what happens when a Git process gets killed by someone,
or there is a system crash, and then we try to run Git again on the
repository.

When I run git-commit after adding a few files to the repository, git
updates the .git/refs/heads/master file using rename() to complete the
commit. Just before this, git appends some meta-information to the
.git/logs/HEAD file. If a crash happens such that one of these
operations has been issued but the other has not, then, running
git-reflog in the future seems to silently show wrong information.
Specifically, the HEAD@{} and the message of one commit (either the
in-transaction commit that was being performed during the crash, or
the previous commit) is shown against the commit number of the other
commit. (I am running git-2.0.4.)

The situation can be reproduced by killing a git process between the
append and the rename, using GDB. (Such a crash can also be caused
when a file system buffers only one of the operations for a longer
time and a kernel OOPS happens in-between. Typical re-ordering file
systems such as ext4-ordered buffer the append longer than the rename,
leading to about a 25 second window in-between).

A disclaimer: I am more involved in file system research than in using
Git expertly, and only noticed this issue while examining Git for a
research project. There is a chance that git-reflog is supposed to
output the information it currently outputs, and I am simply expecting
the wrong thing from it. Also, we have found a couple of places where
Git might act wrongly in the event of a system crash if a re-ordering
file system is used, apart from the usual fsync-before-rename
concerns; these, however, require unusual re-orderings that are not
done by most usual file systems. I have not reported them because I
get the sense that Git is written for an ordered file system; do let
me know if reporting these will be useful.

Example wrong outputs from git reflog:
----
1f9cd01 HEAD@{0}: commit: test2
1f9cd01 HEAD@{1}: commit (initial): test1
----
----
4550c4a HEAD@{0}: commit (initial): test1
----

Expected output:
----
4550c4a HEAD@{0}: commit: test2
1f9cd01 HEAD@{1}: commit (initial): test1
----

Thanks,
Thanu
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to