Re: [PATCH v4 2/9] odb/transaction: add transaction finalize interface

Patrick Steinhardt <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
On Wed, Aug 19, 2026 at 04:53:04PM -0500, Justin Tobler wrote:
> When committing an ODB transaction via `odb_transaction_commit()`, the
> staged objects are made visible and the underlying transaction is freed
> at the same time. Coupling these two steps does not leave room for any
> post-commit transaction operations to be introduced though. Such a
> capability is useful if an ODB transaction backend needs to hold on to
> lockfiles after transaction commit until references are updated, as is
> the case with the existing "files" backend in git-receive-pack(1).
> 
> Stop freeing the transaction in `odb_transaction_commit()` and introduce
> `odb_transaction_finalize()` to explicitly clean up the transaction
> accordingly. Note that the finalize interface also provides an optional
> callback for any backend-specific deferred cleanup. In a subsequent
> commit, the "files" transaction backend will use this to remove ".keep"
> files generated for packfiles received via git-receive-pack(1) after
> references have been updated. In preparation for this, the
> `odb_transaction_finalize()` call site in git-receive-pack(1) is made
> after the reference updates are finished.
> 
> All other callers commit a transaction and immediately finalize it with
> no work in between and cannot meaningfully recover should either fail,
> so introduce an `odb_transaction_commit_and_finalize_or_die()` helper
> that performs both and dies on error. Call sites are updated
> accordingly.

That paragraph is a bit hard to read. How about:

    All other callers commit a transaction and immediately finalize it
    without any work happening in between those two operations.
    Consequently, they cannot meaningfully recover in case either of
    them would fail, and spelling out these two separate steps with
    proper error handling would be quite repetitive and pointless.
    Introduce a helper `odb_transaction_commit_and_finalize_or_die()` to
    help those call sites and update them accordingly.

Patrick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.