git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 16:09 UTC

Re: [PATCH 1/2] object-file: lift ODB reprepare out of packfile flush

From
Justin Tobler <jltobler@gmail.com>
Date
Sep 23, 2026, 21:04 UTC
Message-ID
<arQ8nsUzg9atdCeD@denethor>
In-Reply-To
<arPQrtYHen3UAvdk@pks.im>
On 26/09/23 03:16PM, Patrick Steinhardt wrote:
Show 40 quoted lines
> On Sun, Sep 13, 2026 at 03:26:21PM -0500, Justin Tobler wrote:
> > diff --git a/object-file.c b/object-file.c
> > index a4cbf8b081df..0f123b79fad1 100644
> > --- a/object-file.c
> > +++ b/object-file.c
> > @@ -909,8 +907,10 @@ static int odb_transaction_files_write_object_stream(struct odb_transaction *bas
> >  	 * to zlib compression and is sufficient for this check.
> >  	 */
> >  	if (state->nr_written && pack_size_limit_cfg &&
> > -	    pack_size_limit_cfg < state->offset + stream->size)
> > +	    pack_size_limit_cfg < state->offset + stream->size) {
> >  		flush_packfile_transaction(transaction);
> > +		odb_reprepare(transaction->base.source->odb);
> > +	}
> >  
> >  	CALLOC_ARRAY(idx, 1);
> >  	prepare_packfile_transaction(transaction);
> > @@ -1260,6 +1260,7 @@ static int odb_transaction_files_commit(struct odb_transaction *base)
> >  {
> >  	struct odb_transaction_files *transaction =
> >  		container_of(base, struct odb_transaction_files, base);
> > +	int have_packfile = !!transaction->packfile.f;
> >  
> >  	if (transaction->objdir) {
> >  		struct strbuf temp_path = STRBUF_INIT;
> > @@ -1293,6 +1294,9 @@ static int odb_transaction_files_commit(struct odb_transaction *base)
> >  
> >  	flush_packfile_transaction(transaction);
> >  
> > +	if (have_packfile)
> > +		odb_reprepare(transaction->base.source->odb);
> > +
> >  	return 0;
> >  }
> 
> One thing that I'm curious about: we don't have any error checking for
> flushing the object directory at alll. So there is actually a change in
> behaviour here, where we now also reprepare in case flushing has failed.
> It probably doesn't matter much, but it does raise the question whether
> we may want to start checking for errors.

Regarding the behavior change, I'm not entirely sure I follow. `flush_packfile_transaction()` only returns early in the case where there is nothing to flush. In both of the above call sites, `odb_reprepare()` is only invoked in the same circumstance.

I do agree with the sentiment that error handling could be improve here as most errors are simply handled by die()'ing in place. I'll probably defer doing that as part of this series though.

Thanks, -Justin

Previous: Patrick SteinhardtNext: Justin Tobler
Message 10 of 18 in “object-file: fix packfile flush during transaction commit”
  1. 0/2 object-file: fix packfile flush during transaction commitJustin Tobler, Sep 13, 2026
  2. 1/2 object-file: lift ODB reprepare out of packfile flushJustin Tobler, Sep 13, 2026
  3. 2/2 object-file: flush transaction packfile before migrating objectsJustin Tobler, Sep 13, 2026
  4. Karthik NayakSep 15, 2026
  5. Karthik NayakSep 15, 2026
  6. Justin ToblerSep 15, 2026
  7. Justin ToblerSep 15, 2026
  8. Patrick SteinhardtSep 23, 2026
  9. Patrick SteinhardtSep 23, 2026
  10. Justin ToblerSep 23, 2026
  11. Justin ToblerSep 23, 2026
  12. 0/2 object-file: fix packfile flush during transaction commitJustin Tobler, Sep 23, 2026
  13. 1/2 object-file: lift ODB reprepare out of packfile flushJustin Tobler, Sep 23, 2026
  14. 2/2 object-file: flush transaction packfile before migrating objectsJustin Tobler, Sep 23, 2026
  15. Patrick SteinhardtSep 24, 2026
  16. Patrick SteinhardtSep 24, 2026
  17. Patrick SteinhardtSep 24, 2026
  18. Patrick SteinhardtSep 24, 2026

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.