From: Junio C Hamano <gitster@pobox.com>
To: Robin Rosenberg <robin.rosenberg.lists@dewire.com>
Cc: Git ML <git@vger.kernel.org>, "Shawn O. Pearce" <spearce@spearce.org>
Subject: Re: gc considered dangerous
Date: Sun, 08 Feb 2009 12:09:17 -0800 [thread overview]
Message-ID: <7vab8wy9le.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <200902080347.25970.robin.rosenberg.lists@dewire.com> (Robin Rosenberg's message of "Sun, 8 Feb 2009 03:47:25 +0100")
Robin Rosenberg <robin.rosenberg.lists@dewire.com> writes:
> I've seen this. Running git gc on Windows, while having Elipse open can kill your
> object database.
>
> Eclipse keeps the pack files open most of the time. Then you
> launch git gui which recommends the user to do a git gc. I never
> do (it *always* wants to do this), so I haven't encountered the
> issue, but if gc doesn't find a new optimal pack it tries to rewrite a
> new pack with the same id. So it rm's the idx file (fine) and the the
> pack file (not ok) and gives up, which means it has a .pack file with
> no index, so it cannot use it. Trying git gc again after eclipse exits
> will execute the final stab on your objects.
>
> The underlying bug is ofcource that Windows locks files when
> they are open. A *nix* user does not suffer from this problem.
>
> I'll investigate more at some other time. This is a preliminary
> analysis.
That sounds like you are hitting this codepath in git-repack.sh:
fullbases="$fullbases pack-$name"
chmod a-w "$PACKTMP-$name.pack"
chmod a-w "$PACKTMP-$name.idx"
mkdir -p "$PACKDIR" || exit
for sfx in pack idx
do
if test -f "$PACKDIR/pack-$name.$sfx"
then
mv -f "$PACKDIR/pack-$name.$sfx" \
"$PACKDIR/old-pack-$name.$sfx"
fi
done &&
mv -f "$PACKTMP-$name.pack" "$PACKDIR/pack-$name.pack" &&
mv -f "$PACKTMP-$name.idx" "$PACKDIR/pack-$name.idx" &&
test -f "$PACKDIR/pack-$name.pack" &&
test -f "$PACKDIR/pack-$name.idx" || {
echo >&2 "Couldn't replace the existing pack with updated one."
echo >&2 "The original set of packs have been saved as"
echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR."
exit 1
}
rm -f "$PACKDIR/old-pack-$name.pack" "$PACKDIR/old-pack-$name.idx"
We created a pack and an idx successfully in a pair of temporary files, we
notice that pack-$name.idx and/or pack-$name.pack exists and try to move
them out of the way, then we install the new ones in their final
destination, and we try to see if that move succeeded. If any one of
these steps fails, the entire process fails, but along the way we
shouldn't have lost anything.
I see if .pack can be renamed but .idx can't, then it is possible to get
into a state where you have to mix and match pack-$name.pack and
old-pack-$name.idx.
prev parent reply other threads:[~2009-02-08 20:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-08 2:47 gc considered dangerous Robin Rosenberg
2009-02-08 14:34 ` Robin Rosenberg
2009-02-08 14:56 ` Johannes Schindelin
2009-02-08 16:04 ` Robin Rosenberg
2009-02-08 17:18 ` Johannes Schindelin
2009-02-08 18:24 ` Steffen Prohaska
2009-02-08 19:37 ` Robin Rosenberg
2009-02-08 20:00 ` Junio C Hamano
2009-02-08 20:08 ` Robin Rosenberg
2009-02-08 20:10 ` Robin Rosenberg
2009-02-09 6:59 ` Mike Hommey
2009-02-09 7:43 ` Junio C Hamano
2009-02-08 20:09 ` Junio C Hamano [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vab8wy9le.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg.lists@dewire.com \
--cc=spearce@spearce.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.
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 NNTP newsgroup(s).