git fsck not identifying corrupted packs
Hi,
I have a pack that contains a corrupted object. It is an old corrupted repo that I have conserved.
As expected, git gc cries out loud about it.
It indicates an inflate error (data stream error with incorrect data check), and then the impossibility to read an object from a certain offset in the pack.
However, git fsck does not complain at all about the repo.
I guess that for speed reasons, git fsck does not try to inflate the objects.
Is there a means to have fsck to a truly full check on the sanity of a repo?
This both on git 1.6.5.1 and 1.6.4.2.
Thanks
Sergio Callegari
Quoted 1 line · Sergio Callegari
Is there a means to have fsck to a truly full check on the sanity of a repo?
git fsck --full
RTFM, please.
-- Hannes
Quoted 10 lines · Johannes Sixt
Quoted 2 lines · Sergio Callegari
Is there a means to have fsck to a truly full check on the sanity of a repo?
git fsck --full
RTFM, please.
Right... sorry for the noise, I mismatched --strict for --full in a script.
BTW, the short help for fsck at --full only says "consider objects in alternate repositories".
My apologize.
Sergio
Hi,
Quoted 7 lines · Johannes Sixt
Quoted 2 lines · Sergio Callegari
Is there a means to have fsck to a truly full check on the sanity of a repo?
git fsck --full
RTFM, please.
Now, now.
If you were to test a new filesystem, say, wonderfulfs, and wanted to check its integrity, would you not just run "fsck-wonderfulfs" if that exists, rather than reading the fantamagastic manual? Would you not expect that it Does The Right Thing? Would you not expect that it follows the Law Of Minimal Surprise?
So FWIW I can see where Sergio is coming from.
Ciao,
Dscho
Quoted 7 lines · On Monday 19 October 2009 04:56:07 Sergio Callegari wrote:
Quoted 6 lines · Johannes Sixt
Quoted 2 lines · Sergio Callegari
Is there a means to have fsck to a truly full check on the sanity of a repo?
git fsck --full
Quoted 7 lines
Quoted 1 line
RTFM, please.
Right... sorry for the noise, I mismatched --strict for --full in a script.
BTW, the short help for fsck at --full only says "consider objects in alternate repositories".
Until I read this thread, I didn't realize you needed --full to check objects in packs.
Since just every git repository I ever use has 99%+ of it's objects in packs, this means every time I've run "git fsck" it's essentially been a no-op and I didn't know it. I imagine this is a common confusion.
Also, having --full mean both "check alternate object pools", and "check objects in packs" seems to be rolling up two orthogonal issues.
But anyway, here is a patch that at least fixes the short option help to match the manual and the current behavior:
--- 8< ---
From 8fc3cd68d496bf00faad4f0a7b6ae4fee9437e68 Mon Sep 17 00:00:00 2001
From: Wesley J. Landaker <[email protected]>
Date: Mon, 19 Oct 2009 12:48:07 -0600
Subject: [PATCH] Update git fsck --full short description to mention packs
The '--full' option to git fsck does two things:
1) Check objects in packs
2) Check alternate objects
This is documented in the git fsck manual; this patch reflects that in the short git fsck option help message as well.
--- builtin-fsck.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
builtin-fsck.c +1 -1
@@ -576,7 +576,7 @@ static struct option fsck_opts[] = {OPT_BOOLEAN (0 ,"root" , &show_root,"report root nodes" ),OPT_BOOLEAN (0 ,"cache" , &keep_cache_objects,"make index objects head nodes" ),OPT_BOOLEAN (0 ,"reflogs" , &include_reflogs,"make reflogs head nodes (default)" ), -OPT_BOOLEAN (0 ,"full" , &check_full,"also consider alternate objects" ), +OPT_BOOLEAN (0 ,"full" , &check_full,"also consider packs and alternate objects" ),OPT_BOOLEAN (0 ,"strict" , &check_strict,"enable more strict checking" ),OPT_BOOLEAN (0 ,"lost-found" , &write_lost_and_found, "write dangling objects in .git/lost-found"),
Signature · 1 line
1.6.5
Quoted 2 lines · Wesley J. Landaker
Until I read this thread, I didn't realize you needed --full to check objects in packs.
Same here.
builtin-fsck.c static struct option fsck_opts[] = { · line 579
Quoted 2 lines
builtin-fsck.c +1
-1- OPT_BOOLEAN(0, "full", &check_full, "also consider alternate objects"), + OPT_BOOLEAN(0, "full", &check_full, "also consider packs and alternate objects"),
IMHO, something like this should be applied to "maint", this is kind of a serious bug indeed. Just check the "alternate" thing, according to Junio:
Quoted 5 lines · Junio C Hamano
Side note. I think the help description of --full option is wrong (or at least stale). We always look at alternate object store these days since e15ef66 (fsck: check loose objects from alternate object stores by default, 2009-01-30). It probably should read "check packed objects fully" or something.
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Quoted 12 lines · Johannes Schindelin
Quoted 7 lines · Johannes Sixt
Quoted 2 lines · Sergio Callegari
Is there a means to have fsck to a truly full check on the sanity of a repo?
git fsck --full
RTFM, please.
Now, now.
Quoted 7 lines
If you were to test a new filesystem, say, wonderfulfs, and wanted to check its integrity, would you not just run "fsck-wonderfulfs" if that exists, rather than reading the fantamagastic manual? Would you not expect that it Does The Right Thing? Would you not expect that it follows the Law Of Minimal Surprise?
So FWIW I can see where Sergio is coming from.
Linus and other git developers from the early days trained their fingers to type the command, every once in a while even without thinking, to check the consistency of the repository back when the lower core part of the git was still being developed. Developers who wanted to make sure that git correctly dealt with packfiles could deliberately trigger their creation and checked them after they were created carefully, but loose objects are the ones that are written by various commands from random codepaths. It made some technical sense to have a mode that checked only loose objects from the debugging point of view for that reason.
Side note. I think the help description of --full option is wrong (or at least stale). We always look at alternate object store these days since e15ef66 (fsck: check loose objects from alternate object stores by default, 2009-01-30). It probably should read "check packed objects fully" or something.
The above paragraph is merely a historical background, and in this case the "history" refers to early-to-mid 2005. Even for git developers there no longer is any reason to type "git fsck" in fear of some newly created objects might be corrupt due to recent change to git these days.
The reason we did not make "--full" the default is probably we trust our filesystems a bit too much. At least, we trusted filesystems more than we trusted the lower core part of git that was under development ;-)
Once a packfile is created and we always use it read-only, there didn't seem to be much point in suspecting that the underlying filesystems or disks may corrupt them in such a way that is not caught by the SHA-1 checksum over the entire packfile and per object checksum. That trust in the filesystems might have been a good tradeoff between fsck performance and reliability on platforms git was initially developed on and for, but it might not be true anymore as we run on more platforms these days.
It probably makes sense to ship 1.7.0 with a version of "fsck" in which "--full" is the default; it would still accept "--full" but it would be a no-op. This would be a backward incompatible change, but the difference is primarily about performance ("it takes a lot longer than before!"), and not correctness, so we probably can live with it. As I already said, there is not much reason to run "fsck" every five minutes anymore to begin with (unless your filesystem is so unreliable that it might eat one file every five minutes, that is).
It probably is also a good idea to add a "--loose" option that does what "fsck" currently does without "--full". It is a good name because (1) to people who do not know the internal of git, it means "check only loosely", which would discourage them from running "fack" with that option to begin with, and (2) to others, it exactly tells what the option makes the command check.
(Not CCing everyone, since this is mostly curiosa in the "using git as it was never intended" section):
Quoted 7 lines · On Monday 19 October 2009 13:03:42 Junio C Hamano wrote:
Once a packfile is created and we always use it read-only, there didn't seem to be much point in suspecting that the underlying filesystems or disks may corrupt them in such a way that is not caught by the SHA-1 checksum over the entire packfile and per object checksum. That trust in the filesystems might have been a good tradeoff between fsck performance and reliability on platforms git was initially developed on and for, but it might not be true anymore as we run on more platforms these days.
Filesystems are mostly reliable, but only until your crazy users do strange and terrible things. I have a real, non-toy environment where I use this stack as a [horrible] workaround for some issues beyond my control:
git -> ext4 -> lvm -> dmcrypt -> loop -> sshfs -> cygwin sshd -> SMB share
Amazingly, this works pretty reliably with many gigabytes of data in a git repository, even with the occasional crash because of flakiness with the "sshfs -> cygwin sshd" piece of the puzzle. But a good "git fsck" sure doesn't hurt in this environment! =)
måndag 19 oktober 2009 21:27:48 skrev Wesley J. Landaker:
Quoted 12 lines
(Not CCing everyone, since this is mostly curiosa in the "using git as it was never intended" section):
Quoted 7 lines · On Monday 19 October 2009 13:03:42 Junio C Hamano wrote:
Once a packfile is created and we always use it read-only, there didn't seem to be much point in suspecting that the underlying filesystems or disks may corrupt them in such a way that is not caught by the SHA-1 checksum over the entire packfile and per object checksum. That trust in the filesystems might have been a good tradeoff between fsck performance and reliability on platforms git was initially developed on and for, but it might not be true anymore as we run on more platforms these days.
Quoted 5 lines
Filesystems are mostly reliable, but only until your crazy users do strange and terrible things. I have a real, non-toy environment where I use this stack as a [horrible] workaround for some issues beyond my control:
git -> ext4 -> lvm -> dmcrypt -> loop -> sshfs -> cygwin sshd -> SMB share
The obvious follow up question here is: Why?
-- robin
Quoted 3 lines · On Tuesday 20 October 2009 09:41:50 Robin Rosenberg wrote:
måndag 19 oktober 2009 21:27:48 skrev Wesley J. Landaker:
Quoted 2 lines
(Not CCing everyone, since this is mostly curiosa in the "using git as it was never intended" section):
[...]
Quoted 7 lines
Quoted 7 lines
Filesystems are mostly reliable, but only until your crazy users do strange and terrible things. I have a real, non-toy environment where I use this stack as a [horrible] workaround for some issues beyond my control:
git -> ext4 -> lvm -> dmcrypt -> loop -> sshfs -> cygwin sshd -> SMB share
My main point was to illustrate that having "git fsck" do a REALLY GOOD CHECK is still desirable, as we still haven't reached the days of file- system utopia where nothing ever gets corrupted (even with a smaller, simpler stack).
The actual application where I use this stack is because of odd requirements and circumstances like data must be physically stored on a particular Windows server on the network that uses a weird authentication method that samba doesn't support, and it has to go over the network encrypted anyway, there are lots of holes in the data, so I want ext4 for the extent support, file-size limitations on the target, etc.
It's a really an exotic love-hate mix between an off-by-one-please-no-never- again kind of situation coupled with a bit of "because I can".
Quoted 1 line
The obvious follow up question here is: Why?
If you are both nerdy and morbidly curious enough to care, send me a "but, no ... really, WHY?!" with the git list CC dropped and we can talk about details and/or other crazy stuff. (I don't want to get wildly off-topic on this list.)
Quoted 1 line · Junio C Hamano
Linus and other git developers from the early days [...]
Thanks for the historical background.
Quoted 3 lines
It probably makes sense to ship 1.7.0 with a version of "fsck" in which "--full" is the default; it would still accept "--full" but it would be a no-op.
+1
Quoted 2 lines
It probably is also a good idea to add a "--loose" option that does what "fsck" currently does without "--full". It is a good name
+1 too.
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
Quoted 10 lines · Matthieu Moy
Quoted 1 line · Junio C Hamano
Linus and other git developers from the early days [...]
Thanks for the historical background.
Quoted 3 lines
It probably makes sense to ship 1.7.0 with a version of "fsck" in which "--full" is the default; it would still accept "--full" but it would be a no-op.
Quoted 6 lines
+1
Quoted 2 lines
It probably is also a good idea to add a "--loose" option that does what "fsck" currently does without "--full". It is a good name
+1 too.
Actually, I changed my mind. I do not think this so big that we need to wait for a major version bump. Why not shoot for 1.6.6?
Quoted 8 lines · Junio C Hamano
Quoted 4 lines · Matthieu Moy
Quoted 2 lines
It probably is also a good idea to add a "--loose" option that does what "fsck" currently does without "--full". It is a good name
+1 too.
Actually, I changed my mind. I do not think this so big that we need to wait for a major version bump. Why not shoot for 1.6.6?
--no-full works
Hi,
Quoted 11 lines · Alex Riesen
Quoted 8 lines · Junio C Hamano
Quoted 4 lines · Matthieu Moy
Quoted 2 lines
It probably is also a good idea to add a "--loose" option that does what "fsck" currently does without "--full". It is a good name
+1 too.
Actually, I changed my mind. I do not think this so big that we need to wait for a major version bump. Why not shoot for 1.6.6?
--no-full works
It works. Technically. For human users, though, --loose-objects-only (with a shortcut "--loose") would be better.
Disclaimer: this email was written by a bot and is valid without signature
Quoted 5 lines · Johannes Schindelin
Hi,
Quoted 1 line · Alex Riesen
On Tue, Oct 20, 2009 at 08:45, Junio C Hamano <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines · Matthieu Moy
Quoted 2 lines
It probably is also a good idea to add a "--loose" option that does what "fsck" currently does without "--full". It is a good name
--no-full works
It works. Technically. For human users, though, --loose-objects-only (with a shortcut "--loose") would be better.
OTOH, the advantage of "--no-full" is that it's compatible with existing Git versions. If I learn Git 1.6.6 with --no-full, and use it in a script, then my stript works also with older Gits.
But anyway, I think very few people are actually interested in "git --no-full" (or call it whatever you like), so I don't think this is very important.
Signature · 2 lines
Matthieu Moy http://www-verimag.imag.fr/~moy/
[RFC/PATCH] fsck: default to "git fsck --full"
Linus and other git developers from the early days trained their fingers to type the command, every once in a while even without thinking, to check the consistency of the repository back when the lower core part of the git was still being developed. Developers who wanted to make sure that git correctly dealt with packfiles could deliberately trigger their creation and checked them after they were created carefully, but loose objects are the ones that are written by various commands from random codepaths. It made some technical sense to have a mode that checked only loose objects from the debugging point of view for that reason.
Even for git developers, there no longer is any reason to type "git fsck" every five minutes these days, worried that some newly created objects might be corrupt due to recent change to git.
The reason we did not make "--full" the default is probably we trust our filesystems a bit too much. At least, we trusted filesystems more than we trusted the lower core part of git that was under development.
Once a packfile is created and we always use it read-only, there didn't seem to be much point in suspecting that the underlying filesystems or disks may corrupt them in such a way that is not caught by the SHA-1 checksum over the entire packfile and per object checksum. That trust in the filesystems might have been a good tradeoff between fsck performance and reliability on platforms git was initially developed on and for, but it may not be true anymore as we run on many more platforms these days.
---
Quoted 9 lines · Matthieu Moy
Johannes Schindelin <[email protected]> writes:
...Quoted 6 lines · Alex Riesen
...
Quoted 1 line
--no-full works
It works. Technically. For human users, though, --loose-objects-only (with a shortcut "--loose") would be better.
Quoted 7 lines
OTOH, the advantage of "--no-full" is that it's compatible with existing Git versions. If I learn Git 1.6.6 with --no-full, and use it in a script, then my stript works also with older Gits.
But anyway, I think very few people are actually interested in "git --no-full" (or call it whatever you like), so I don't think this is very important.
For human users, I think --full vs --no-full is quite a nice suggestion, given that we already have advertised --full and people know the option.
Also people know that splicing "no-" after the double dash is often the way to negate a boolean-looking option.
The actual patch to do this is tiny, but that is just a bonus ;-)
Documentation/RelNotes-1.6.6.txt | 10 ++++++++++ Documentation/git-fsck.txt | 5 +++-- builtin-fsck.c | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-)
Documentation/RelNotes-1.6.6.txt +10 -0
@@ -1,6 +1,13 @@ GIT v1.6.6 Release Notes ======================== +In this release, "git fsck" defaults to "git fsck --full" and checks +packfiles. If you prefer a quicker check only on loose objects (the +old default), you can say "git fsck --no-full". This has been +supported by 1.5.4 and newer versions of git, so it is safe to write +it in your script if you use slightly older git on some of your +machines. + In git 1.7.0, which is planned to be the release after 1.6.6, "git push" into a branch that is currently checked out will be refused by default.
@@ -38,6 +45,9 @@ Updates since v1.6.5 (usability, bells and whistles) + * "git fsck" by default checks the packfiles (i.e. "--full" is the + default); you can turn it off with "git fsck --no-full". + * "git log --decorate" shows the location of HEAD as well. (developers)
Documentation/git-fsck.txt +3 -2
@@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git fsck' [--tags] [--root] [--unreachable] [--cache] [--no-reflogs] - [--full] [--strict] [--verbose] [--lost-found] [<object>*] + [--[no-]full] [--strict] [--verbose] [--lost-found] [<object>*] DESCRIPTION -----------
@@ -52,7 +52,8 @@ index file, all SHA1 references in .git/refs/*, and all reflogs (unless or $GIT_DIR/objects/info/alternates, and in packed git archives found in $GIT_DIR/objects/pack and corresponding pack subdirectories in alternate - object pools. + object pools. This is now default; you can turn it off + with --no-full. --strict:: Enable more strict checking, namely to catch a file mode
builtin-fsck.c +1 -1
@@ -19,7 +19,7 @@ static int show_root;static int show_tags;static int show_unreachable;static int include_reflogs =1 ; -static int check_full; +static int check_full =1 ;static int check_strict;static int keep_cache_objects;static unsigned char head_sha1[20 ];
Re: [RFC/PATCH] fsck: default to "git fsck --full"
Documentation/RelNotes-1.6.6.txt line 5
Quoted 10 lines · Junio C Hamano
Documentation/RelNotes-1.6.6.txt +2
-0@@ -1,6 +1,13 @@ GIT v1.6.6 Release Notes ======================== +In this release, "git fsck" defaults to "git fsck --full" and checks +packfiles. If you prefer a quicker check only on loose objects (the
^^
Might be worth mentioning explicitly that, because of that change, plain fsck is now going to take much longer to complete.
Nicolas
Re: [RFC/PATCH] fsck: default to "git fsck --full"
Quoted 10 lines · Nicolas Pitre
Quoted 8 lines · Junio C Hamano
Documentation/RelNotes-1.6.6.txt +0
-0@@ -1,6 +1,13 @@ GIT v1.6.6 Release Notes ========================
Quoted 6 lines
Documentation/RelNotes-1.6.6.txt line 5
Quoted 2 lines
Documentation/RelNotes-1.6.6.txt +2
-0+In this release, "git fsck" defaults to "git fsck --full" and checks +packfiles. If you prefer a quicker check only on loose objects (the^^Might be worth mentioning explicitly that, because of that change, plain fsck is now going to take much longer to complete.
Sounds fair; thanks.
Documentation/RelNotes-1.6.6.txt +2 -1
@@ -2,7 +2,8 @@ GIT v1.6.6 Release Notes ======================== In this release, "git fsck" defaults to "git fsck --full" and checks -packfiles. If you prefer a quicker check only on loose objects (the +packfiles, and because of this it will take much longer to complete +than before. If you prefer a quicker check only on loose objects (the old default), you can say "git fsck --no-full". This has been supported by 1.5.4 and newer versions of git, so it is safe to write it in your script even if you use slightly older git on some of your
Quoted 2 lines · Junio C Hamano
Actually, I changed my mind. I do not think this so big that we need to wait for a major version bump. Why not shoot for 1.6.6?
Agreed. With a prominent note in the release notes to point people at it when they don't read release notes and complain that fsck suddenly became very slow after they upgraded.
Nicolas
Quoted 8 lines · Nicolas Pitre
Quoted 2 lines · Junio C Hamano
Actually, I changed my mind. I do not think this so big that we need to wait for a major version bump. Why not shoot for 1.6.6?
Agreed. With a prominent note in the release notes to point people at it when they don't read release notes and complain that fsck suddenly became very slow after they upgraded.
I have a feeling that it either wont be noticed at all (i.e., I have run fsck with something other than --full only one time in my whole bash history, and never shown it otherwise to anyone else), or people will immediately like it ("Oh, finallly! Now that feels like it is doing something!" :)
Quoted 5 lines · Johannes Sixt
Quoted 1 line
Is there a means to have fsck to a truly full check on the sanity of a repo?
git fsck --full
RTFM, please.
That still does not catch everything. About a week ago I wanted to check out a branch in a local repo and I got an error that it was corrupt. But "git fsck --full" only complained about some dangling objects, it did not notice the corruption. I used git version 1.6.4.3 (Debian unstable at that time). It would be nice to have a
"git fsck --i-really-want-to-check-everything".
Gabor
Signature · 4 lines
---------------------------------------------------------
MTA SZTAKI Computer and Automation Research Institute
Hungarian Academy of Sciences
---------------------------------------------------------