Disappearing Git commit -- wtf happened?

Status
Not open for further replies.

dredphul

Ars Tribunus Angusticlavius
6,349
Subscriptor++
Ran into a strange issue with git.

A dev's commit to a project disappeared a day later (we know the that the commit occurred from the Jenkins build email). The commit was missing from the dev's checkout (we think a 'git pull' may have overwritten the update he originally made. He ended up recoding the change and committing it again.

A normal 'git log' wouldn't show the original commit. If I did 'git log full-history', I can see the missing commit.

I can run 'git show' to see the diffs made in the first and second commits of the change.

Some Google searches bring up the possibility that someone reverted the commit in a merge. I've looked at merges in the time period and I don't see any merges that include the affected file.

Anyone have any idea what might have happened? I know that you can rewrite history with 'git rebase', but in situations where a dev abused rebase, you get a conflict message the next time you do a fetch/pull. I never got a error from git pulls in the past 2 days and as far as I know none of the other devs got one either.
 

Jonathon

Ars Legatus Legionis
17,647
Subscriptor
Still, the fact that the commit disappeared from the original dev's local repo is concerning. Under basically no circumstances should a git commit end up "lost" after a pull or fetch without doing 'git pull --force' or similar. Git throws a nice big warning if you try to pull (or push, for that matter) and something would get deleted.

Are you sure he didn't commit on a different branch or produce the commit while his working copy was in a detached HEAD state (had done 'git checkout <commit>' where commit is a commit hash or tag, not a branch, and hadn't returned to a branch before committing)?

(And if you make a habit of using --force... :judge: :p)
 

dredphul

Ars Tribunus Angusticlavius
6,349
Subscriptor++
[url=http:/civis/viewtopic.php?p=25034611#p25034611:1vggsnyz said:
Jonathon[/url]":1vggsnyz]Still, the fact that the commit disappeared from the original dev's local repo is concerning. Under basically no circumstances should a git commit end up "lost" after a pull or fetch without doing 'git pull --force' or similar. Git throws a nice big warning if you try to pull (or push, for that matter) and something would get deleted.

Are you sure he didn't commit on a different branch or produce the commit while his working copy was in a detached HEAD state (had done 'git checkout <commit>' where commit is a commit hash or tag, not a branch, and hadn't returned to a branch before committing)?

The commits were lost due to damage (not sure to what exactly) from letting a nfs mount go to 100% used. People weren't in a detached state and these weren't devs new to git.

Multiple devs committed changes on Wednesday/Thursday and when they did a 'git pull' later on, their commits disappeared without any warning or notice. This is NOT normal and I blame corruption/damage from the full disk issue.

Trying to fix the issue with 'git merge sha1-of-commit' didn't work. I couldn't find a way in git (v1.8.3.1) to force the merge. I ended up 'fixing' the issue by getting the missing commit (by running 'git checkout sha1-of-commit') and manually copying the file(s) to a secondary checkout and doing a 'git add'/'git commit'/'git push'.

One funny thing was some of the missing files would magically reappear after I fixed a few missing commits. I don't know whether that's a good thing or not. I'm uncomfortable with things magically fixing themselves.
 

dredphul

Ars Tribunus Angusticlavius
6,349
Subscriptor++
The commits were there, but only visible if you did 'git log --full-history' or 'git show <sha1hash>'.

Tried several ways to make the commits visible and the HEAD of the file, but nothing worked outside of copying the file into a new checkout.

Checked the reflogs, but I didn't see anything useful. Don't know enough about Git internal data structures to know what I'm looking for really.

Dev's checkouts weren't on nfs mounts, but on local filesystems (Windows and Mac OS X). A number of the devs with bad commits were using the SmartGit client, but I'm thinking that may be just a coincidence. The git server had all the repos on a nfs mount.

The corruption silently spread to everyone's local repo when anyone did a 'git pull'. Like I mentioned earlier, due to the corruption, normal alerts you'd get from a rewrite of history didn't go off.

Had to work today, partly to fix the bad commits for a project getting released in a few days. Found out the situation is worse than I thought as I was focused just on the main repo for the group I work in. The git server hosts git repos for a couple other groups.

Wrote a shell script that will go through each and every file in a repo to see if there is any corruption, it generates false alarms, but I'll polish it a bit more to filter them out.

I get to run the script across 10+ repos, with multiple active branches per repo tomorrow. :rolleyes:

Will also be having a talk with the systems group about monitoring and backups of the git server.
 

dredphul

Ars Tribunus Angusticlavius
6,349
Subscriptor++
[url=http:/civis/viewtopic.php?p=25040679#p25040679:3haultao said:
MilleniX[/url]":3haultao]At any point in this, has anyone run 'git fsck' on an affected repo? If not, you really, really should. You should probably also bring the results to the Git developers mailing list, since it should be checking for error conditions and failing noisily, not silently corrupting data.

Yes, I've run git fsck.

It's a little weird (and the reason why I had to write a script) in that if I run 'git fsck --strict' on the repo, no issues are found. But, if I run 'git fsck --strict <sha1-hash>' where the hash is a bad commit, I will get 10 to 20 dangling commits and tags.

Yeah, I'm planning on posting to the dev list, but can't do it anytime soon as the data corruption happened a few days before a big release (Tuesday night, pray for me).
 
Status
Not open for further replies.