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

Re: tree corrupted on disk quota full

From
Linus Torvalds <torvalds@osdl.org>
Date
Jan 11, 2007, 21:50 UTC
Message-ID
<Pine.LNX.4.64.0701111324350.3594@woody.osdl.org>
In-Reply-To
<20070111211143.GG17999@mellanox.co.il>
On Thu, 11 Jan 2007, Michael S. Tsirkin wrote:
> 
> I did lots of resets and they did not seems to help.

NOTE! If "nothing seems to help" means "git-fsck-objects" still complains, then that is very much expected.

"git reset" does NOT fix a corrupted database. Never has, never will. It should only fix the case where a branch head points to a corrupt or incomplete tree.

To actually fix the database, you need to remove the broken objects. Which "git prune" did for you (but you could have just done it by hand too).

> Then, on a hunch, I just did git prune and
> it cleaned the tree so I can pull/push fine.

If so, your branch heads had _already_ been fixed (by one of the resets), and "git prune" just got rid of the (unreachable) objects that were broken.

> How come?
What happens is:
 - you had gotten some corrupt objects due to the disk filling up 
   (probably during the pull that thus populated the object database with
   partially written objects)
   In particular, the 4d4d30be967d3284cbf59afd4fba6ab536e295f5 object was 
   corrupt. fsck gave a confusing error message:
	error: 4d4d30be967d3284cbf59afd4fba6ab536e295f5: object not found
	error: c03590b581d51d5fa43adbef9415e935d0229412: object not found
   which is really because the _file_ for that object does exist, but the 
   file doesn't actually contain the object it expects (due to 
   corruption), so the object wasn't "found". 
 - git-fsck-objects complained about them, but it doesn't actually do 
   anything about it (which you maybe expected it to do - it doesn't 
   really act as a filesystem fsck which tries to _fix_ things, it really 
   just does the "check" part, since "fixing" things is almost always a 
   manual operation)
 - "git prune" actually removed all the unreachable objects, and since 
   none of the _reachable_ objects were broken, that makes 
   git-fsck-objects shut up too.
 - your "git pull" failed, because it was fetching objects that were 
   corrupt in your local database - and the rule is that local objects 
   ALWAYS override remote objects. That's an important security thing (a 
   "pull" is _never_ allowed to overwrite something you already have, and 
   it doesn't matter if it's corrupt or not, you're not ever going to have 
   a "git pull" overwriting old data)
> So it seems the tree was more or less fine (it just has some useless objects
> because of the disk full failure), the bug seems to be that pull/push fail.

Not a bug. See above. It's really a very important safety feature: we never EVER overwrite any old objects. Even if they are corrupt. But it means that you need to _fix_ any corruption in order to use the repository.

That's a security feature. It's a feature because git absolutely ALWAYS considers the "local repository" to be the trustworthy one. It matters not a whit if git thinks a local object may be corrupt - the local copy is _still_ considered to always be the definite copy. It's part of what makes git stable.

You may not think that sounds "stable" to you right now, in that it made it harder to "fix" the problem, but it indirectly means that even a _buggy_ git binary (say, you by mistake use an older git binary that doesn't understand some new object format) will never overwrite data that you already had. That's true safety.

It does mean that if you have a corrupt database, you really do need to fix it first, but it's _still_ a safety feature: git won't fix the database for you "by mistake". You need to fix it consciously.

That's true robustness.
			Linus
Previous: Michael S. TsirkinNext: Michael S. Tsirkin
Message 18 of 24 in “tree corrupted on disk quota full”
  1. Michael S. TsirkinJan 11, 2007
  2. Andreas EricssonJan 11, 2007
  3. Andy WhitcroftJan 11, 2007
  4. Michael S. TsirkinJan 11, 2007
  5. Andreas EricssonJan 11, 2007
  6. Linus TorvaldsJan 11, 2007
  7. Linus TorvaldsJan 11, 2007
  8. Linus TorvaldsJan 11, 2007
  9. Junio C HamanoJan 11, 2007
  10. Andy WhitcroftJan 11, 2007
  11. Junio C HamanoJan 11, 2007
  12. Better error messages for corrupt databasesLinus Torvalds, Jan 11, 2007
  13. Shawn O. PearceJan 12, 2007
  14. Linus TorvaldsJan 11, 2007
  15. Andy WhitcroftJan 11, 2007
  16. Linus TorvaldsJan 11, 2007
  17. Michael S. TsirkinJan 11, 2007
  18. Linus TorvaldsJan 11, 2007
  19. Michael S. TsirkinJan 11, 2007
  20. Linus TorvaldsJan 11, 2007
  21. Michael S. TsirkinJan 11, 2007
  22. Linus TorvaldsJan 12, 2007
  23. Shawn O. PearceJan 12, 2007
  24. Junio C HamanoJan 13, 2007

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.