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

Re: [PATCH] builtin/repack.c: remove redundant pack-based bitmaps

From
Jeff King <peff@peff.net>
Date
Oct 17, 2022, 19:27 UTC
Message-ID
<Y02shQFeXkwYd2g6@coredump.intra.peff.net>
In-Reply-To
<221017.868rlejn4z.gmgdl@evledraar.gmail.com>
On Mon, Oct 17, 2022 at 08:50:07PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 20 quoted lines
> 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
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 4 of 10 in “builtin/repack.c: remove redundant pack-based bitmaps”
  1. builtin/repack.c: remove redundant pack-based bitmapsTaylor Blau, Oct 12, 2022
  2. Jeff KingOct 17, 2022
  3. Ævar Arnfjörð BjarmasonOct 17, 2022
  4. Jeff KingOct 17, 2022
  5. Junio C HamanoOct 17, 2022
  6. Jeff KingOct 17, 2022
  7. Taylor BlauOct 18, 2022
  8. Taylor BlauOct 18, 2022
  9. builtin/repack.c: remove redundant pack-based bitmapsTaylor Blau, Oct 18, 2022
  10. Jeff KingOct 18, 2022

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.