git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: Re: fetching packs and storing them as packs
Date: Fri, 27 Oct 2006 14:53:59 -0700	[thread overview]
Message-ID: <7v3b99e87c.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0610271310450.3849@g5.osdl.org> (Linus Torvalds's message of "Fri, 27 Oct 2006 13:22:18 -0700 (PDT)")

Linus Torvalds <torvalds@osdl.org> writes:

> We really should _never_ create a pack in-place with the final name.

The "fattening" index-pack Nico did does not have this problem
as far as I can see.  Under --stdin, it creates a temporary pack
file "$GIT_OBJECT_DIRECTORY/pack_XXXXXX"; after the received
pack is fattened by adding missing delta-base objects and fixing
up the pack header, final() moves the {pack,idx} pair to the
final location.

The race is about this sequence:

	- git-receive-pack is spawned from remove git-send-pack;
          it lets "index-pack --stdin --fatten" to keep the pack.

	- index-pack does its magic and moves the pack and idx
          to their final location;

	- "repack -a -d" is started by somebody else; it first
          remembers all the existing packs; it does the usual
          repacking-into-one.

	- git-receive-pack that invoked the index-pack waits for
          index-pack to finish, and then updates the refs;

	- "repack -a -d" is done repacking; removes the packs
          that existed when it checked earlier.

Two instances of receive-pack running simultaneously is safe (in
the sense that it does not corrupt the repository; one instance
can fail after noticing the other updated the ref it wanted to
update) and there is no reason to exclude each other.  But
"repack -a -d" and receive-pack are not.

Can we perhaps have reader-writer lock on the filesystem to
pretect the repository?  "prune" can also be made into a writer
for that lock and "fetch-pack --keep" would be a reader for the
lock.  That reader-writer lock would solve the issue rather
nicely.

> That said, I think some of the "git repack -d" logic is also unnecessarily 
> fragile.

Noted; will fix.

  reply	other threads:[~2006-10-27 21:54 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-26  3:44 fetching packs and storing them as packs Nicolas Pitre
2006-10-26 14:45 ` Eran Tromer
     [not found]   ` <Pine.LNX.4.64.0610261105200.12418@xanadu.home>
2006-10-26 22:09     ` Eran Tromer
2006-10-27  0:50       ` Nicolas Pitre
2006-10-27  1:42         ` Shawn Pearce
2006-10-27  2:38           ` Sean
2006-10-27  6:57             ` Junio C Hamano
2006-10-27 17:23               ` Nicolas Pitre
2006-10-27  2:41           ` Nicolas Pitre
2006-10-27  2:42           ` Eran Tromer
2006-10-27  3:00             ` Shawn Pearce
2006-10-27  3:13               ` Sean
2006-10-27  3:20                 ` Jakub Narebski
2006-10-27  3:27                   ` Sean
2006-10-27  4:03               ` Eran Tromer
2006-10-27  4:42                 ` Shawn Pearce
2006-10-27  7:42                   ` Alex Riesen
2006-10-27  7:52                     ` Shawn Pearce
2006-10-27  8:08                       ` Alex Riesen
2006-10-27  8:13                         ` Shawn Pearce
2006-10-27 14:27               ` Nicolas Pitre
2006-10-27 14:38                 ` Petr Baudis
2006-10-27 14:48                   ` J. Bruce Fields
2006-10-27 15:03                     ` Petr Baudis
2006-10-27 16:04                       ` J. Bruce Fields
2006-10-27 16:05                         ` J. Bruce Fields
2006-10-27 18:56                   ` Junio C Hamano
2006-10-27 20:22   ` Linus Torvalds
2006-10-27 21:53     ` Junio C Hamano [this message]
2006-10-28  3:42       ` Shawn Pearce
2006-10-28  4:09         ` Junio C Hamano
2006-10-28  4:18         ` Linus Torvalds
2006-10-28  5:42           ` Junio C Hamano
2006-10-28  7:21             ` Shawn Pearce
2006-10-28  8:40               ` Shawn Pearce
2006-10-28 19:15                 ` Junio C Hamano
2006-10-29  3:50                   ` Shawn Pearce
2006-10-29  4:29                     ` Junio C Hamano
2006-10-29  4:38                       ` Shawn Pearce
2006-10-29  5:16                         ` Junio C Hamano
2006-10-29  5:21                           ` Shawn Pearce
2006-10-28 17:59               ` Linus Torvalds
2006-10-28 18:34               ` Junio C Hamano
2006-10-28 22:31               ` Eran Tromer
2006-10-29  3:38                 ` Shawn Pearce
2006-10-29  3:48                   ` Jakub Narebski
2006-10-29  3:52                     ` Shawn Pearce
2006-10-29  7:47 ` [PATCH] send-pack --keep: do not explode into loose objects on the receiving end Junio C Hamano
2006-10-29  7:56   ` Shawn Pearce
2006-10-29  8:05     ` Junio C Hamano
2006-10-30  1:44     ` Nicolas Pitre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v3b99e87c.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).