git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git fsck not identifying corrupted packs

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 19, 2009, 19:03 UTC
Message-ID
<7v7hur1a0h.fsf@alter.siamese.dyndns.org>
In-Reply-To
<alpine.DEB.1.00.0910191202020.4985@pacific.mpi-cbg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 19 quoted lines
> On Mon, 19 Oct 2009, Johannes Sixt wrote:
>
>> Sergio Callegari schrieb:
>> > 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.

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.

Previous: Johannes SchindelinNext: Wesley J. Landaker
Message 4 of 21 in “git fsck not identifying corrupted packs”
  1. Sergio CallegariOct 19, 2009
  2. Johannes SixtOct 19, 2009
  3. Johannes SchindelinOct 19, 2009
  4. Junio C HamanoOct 19, 2009
  5. Wesley J. LandakerOct 19, 2009
  6. Robin RosenbergOct 20, 2009
  7. Wesley J. LandakerOct 20, 2009
  8. Matthieu MoyOct 20, 2009
  9. Junio C HamanoOct 20, 2009
  10. Alex RiesenOct 20, 2009
  11. Johannes SchindelinOct 20, 2009
  12. Matthieu MoyOct 20, 2009
  13. fsck: default to "git fsck --full"Junio C Hamano, Oct 20, 2009
  14. Nicolas PitreOct 20, 2009
  15. Junio C HamanoOct 20, 2009
  16. Nicolas PitreOct 20, 2009
  17. Alex RiesenOct 20, 2009
  18. Sergio CallegariOct 19, 2009
  19. Wesley J. LandakerOct 19, 2009
  20. Matthieu MoyOct 20, 2009
  21. Gabor GombasOct 19, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.