Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Taylor Blau <me@ttaylorr.com>,
	git@vger.kernel.org, derrickstolee@github.com, vdye@github.com,
	gitster@pobox.com
Subject: Re: [PATCH] builtin/repack.c: remove redundant pack-based bitmaps
Date: Mon, 17 Oct 2022 15:27:01 -0400	[thread overview]
Message-ID: <Y02shQFeXkwYd2g6@coredump.intra.peff.net> (raw)
In-Reply-To: <221017.868rlejn4z.gmgdl@evledraar.gmail.com>

On Mon, Oct 17, 2022 at 08:50:07PM +0200, Ævar Arnfjörð Bjarmason wrote:

> On Mon, Oct 17 2022, Jeff King wrote:
> 
> > On Wed, Oct 12, 2022 at 03:05:33PM -0400, Taylor Blau wrote:
> > [...]
> >> [...]
> >> +	for_each_string_list_item(item, include) {
> >> +		strbuf_addstr(&path, item->string);
> >> +		strbuf_strip_suffix(&path, ".idx");
> >> +		strbuf_addstr(&path, ".bitmap");
> >> +
> >> +		if (unlink(path.buf) && errno != ENOENT)
> >> +			die_errno(_("could not remove stale bitmap: %s"),
> >> +				  path.buf);
> >
> > We could downgrade this to a warning, since there is no downside to
> > retaining those files (aside from wasted space). In
> > remove_redundant_pack(), we call into unlink_pack_path(), which just
> > ignores unlink errors (though arguably it should at least warn).
> 
> An ENOENT would indicate a race with a concurrent process.

In the code above, I don't think it is. We included some packs in the
midx, and we know that their bitmaps (if any) are now redundant. So we
remove them by calling unlink() speculatively, rather than asking "do we
have this file? If so, unlink".

Likewise in remove_redundant_pack(). We are not just removing the
packfiles, but speculatively removing their .rev, .bitmap, .promisor,
etc. If they don't exist, that's perfectly normal. Arguably we could
notice and complain if the .pack or .idx went away in the interim, since
those would indicate a race.

So I think the code above is right to ignore ENOENT. The one in
remove_redundant_pack() does so, too, but it also ignores everything
else.

> But at that point should we be ignoring other unlink() errors?  Maybe we
> should additionally be ignoring EBUSY.

For most errors besides ENOENT, I think a warning is the right thing. It
is OK that we failed to remove the file (it does not make the overall
operation a failure). But it may be helpful for the user to let them
know that the cruft was left (e.g., for EPERM or EIO). And that applies
here and in remove_redundant_pack().

Really, both here and remove_redundant_pack() should probably be using
unlink_or_warn(). Though if you did want to notice the race on deleting
the actual .pack file, it would need to be hand-coded.

-Peff

  reply	other threads:[~2022-10-17 19:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-12 19:05 [PATCH] builtin/repack.c: remove redundant pack-based bitmaps Taylor Blau
2022-10-17 18:02 ` Jeff King
2022-10-17 18:50   ` Ævar Arnfjörð Bjarmason
2022-10-17 19:27     ` Jeff King [this message]
2022-10-17 21:04       ` Junio C Hamano
2022-10-17 21:40         ` Jeff King
2022-10-18  2:38   ` Taylor Blau
2022-10-18  2:43   ` Taylor Blau
2022-10-18  2:45 ` [PATCH v2] " Taylor Blau
2022-10-18  6:29   ` Jeff King

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=Y02shQFeXkwYd2g6@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=derrickstolee@github.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=me@ttaylorr.com \
    --cc=vdye@github.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).