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

Re: fetching packs and storing them as packs

From
Linus Torvalds <torvalds@osdl.org>
Date
Oct 27, 2006, 20:22 UTC
Message-ID
<Pine.LNX.4.64.0610271310450.3849@g5.osdl.org>
In-Reply-To
<4540CA0C.6030300@tromer.org>
On Thu, 26 Oct 2006, Eran Tromer wrote:
Show 7 quoted lines
>
> This creates a race condition w.r.t. "git repack -a -d", similar to the
> existing race condition between "git fetch --keep" and
> "git repack -a -d". There's a point in time where the new pack is stored
> but not yet referenced, and if "git repack -a -d" runs at that point it
> will eradicate the pack. When the heads are finally updated, you get a
> corrupted repository.

(I note that there's a whole thread on this, but I was off doing other things, so I probably missed part of it)

We really should _never_ create a pack in-place with the final name.
The way to fix the race is to simply not create the patch as
	.git/objects/packed/pack-xyz.{pack|idx}

in the first place, but simply "mv" them into place later. If you do that after you've written the temporary pointer to it, there is no race (the temporary pointer may not be usable, of course, but that's a separate issue).

That said, I think some of the "git repack -d" logic is also unnecessarily fragile. In particular, it shouldn't just do

	existing=$(find . -type f \( -name '*.pack' -o -name '*.idx' \))

like it does to generate the "existing" list, it should probably only ever remove a pack-file and index file _pair_, ie it should do something like

	existing=$(find . -type f -name '*.pack')
and then do
	for pack in $existing
	do
		index="$(basename $pack).idx"
		if [ -f $index ] && [ "$pack"!= "$newpack" ]
		then
			rm -f "$pack" "$index"
		fi
	done

etc, exactly so that it would never remove anything that is getting indexed or is otherwise half-way done, regardless of any other issues.

Hmm?
Previous: Eran TromerNext: Junio C Hamano
Message 3 of 51 in “fetching packs and storing them as packs”
  1. Nicolas PitreOct 26, 2006
  2. Eran TromerOct 26, 2006
  3. Linus TorvaldsOct 27, 2006
  4. Junio C HamanoOct 27, 2006
  5. Shawn PearceOct 28, 2006
  6. Junio C HamanoOct 28, 2006
  7. Linus TorvaldsOct 28, 2006
  8. Junio C HamanoOct 28, 2006
  9. Shawn PearceOct 28, 2006
  10. Shawn PearceOct 28, 2006
  11. Junio C HamanoOct 28, 2006
  12. Shawn PearceOct 29, 2006
  13. Junio C HamanoOct 29, 2006
  14. Shawn PearceOct 29, 2006
  15. Junio C HamanoOct 29, 2006
  16. Shawn PearceOct 29, 2006
  17. Linus TorvaldsOct 28, 2006
  18. Junio C HamanoOct 28, 2006
  19. Eran TromerOct 28, 2006
  20. Shawn PearceOct 29, 2006
  21. Jakub NarebskiOct 29, 2006
  22. Shawn PearceOct 29, 2006
  23. send-pack --keep: do not explode into loose objects on the receiving end.Junio C Hamano, Oct 29, 2006
  24. Shawn PearceOct 29, 2006
  25. Junio C HamanoOct 29, 2006
  26. Nicolas PitreOct 30, 2006
  27. Eran TromerOct 26, 2006
  28. Nicolas PitreOct 27, 2006
  29. Shawn PearceOct 27, 2006
  30. SeanOct 27, 2006
  31. Junio C HamanoOct 27, 2006
  32. Nicolas PitreOct 27, 2006
  33. Nicolas PitreOct 27, 2006
  34. Eran TromerOct 27, 2006
  35. Shawn PearceOct 27, 2006
  36. SeanOct 27, 2006
  37. Jakub NarebskiOct 27, 2006
  38. SeanOct 27, 2006
  39. Eran TromerOct 27, 2006
  40. Shawn PearceOct 27, 2006
  41. Alex RiesenOct 27, 2006
  42. Shawn PearceOct 27, 2006
  43. Alex RiesenOct 27, 2006
  44. Shawn PearceOct 27, 2006
  45. Nicolas PitreOct 27, 2006
  46. Petr BaudisOct 27, 2006
  47. J. Bruce FieldsOct 27, 2006
  48. Petr BaudisOct 27, 2006
  49. J. Bruce FieldsOct 27, 2006
  50. J. Bruce FieldsOct 27, 2006
  51. Junio C HamanoOct 27, 2006

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.