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

Re: [PATCH 3/3] bulk-checkin: wire repository variable

From
Justin Tobler <jltobler@gmail.com>
Date
Aug 21, 2025, 20:26 UTC
Message-ID
<rhkhmaozjaogm34xfwagagy2qifsq5p4fbtb23nhdu7jfg2627@qkrv57gg2k3u>
In-Reply-To
<xmqq8qjd7coe.fsf@gitster.g>
On 25/08/20 05:15PM, Junio C Hamano wrote:
Show 6 quoted lines
> I somehow expected that odb would know what repository it was
> instanciated to work with, or in the worst case where in-core odb is
> in theory sharable among multiple in-core repositories, at least
> begin_odb_transaction() would take <repository, odb> pair and the
> transaction would know for which repository the transaction is
> working for.

The `struct odb_transaction` maintains a pointer to its parent `struct object_database`. This ODB also has a pointer to the `struct repository`. Thus, from an ongoing transaction we should be able to get the repository we want.

For `begin_odb_transaction()` we should only have to provide `struct object_database` and from that the transaction can access the corresponding repository. In the general cases, this is exactly what we do, but this doesn't work for `index_blob_bulk_checkin()` and its accompanying internal functions as they may be invoked from outside of a transaction.

> Do we need bulk_checkin_packfile as a separate structure and pass it
> around, or would these internal functions be better off passing an
> instance of odb_transaction around and learn the repository from
> odb->repo?

In its current form, the bulk-checkin mechanism for packfiles may be used outside of transactions. For example when calling `index_blob_bulk_checkin()` without a transaction, the single object is written to the packfile moved into the primary ODB. With a transaction, multiple objects may be written to a single packfile. This whole setup is rather awkward though.

Thinking about this more, we should probably just require `index_blob_bulk_checkin()` be provided a transaction. Callers will need to ensure a transaction is running so that a `struct bulk_checkin_packfile` gets set up, but this shouldn't be a big deal. With this we could easily just propagate the transaction for all these function as you suggested.

I'll do this in the next version. Thanks!
-Justin
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 27 in “bulk-checkin: remove global transaction state”
  1. 0/3 bulk-checkin: remove global transaction stateJustin Tobler, Aug 20, 2025
  2. 1/3 bulk-checkin: introduce object database transaction structureJustin Tobler, Aug 20, 2025
  3. 2/3 bulk-checkin: remove global transaction stateJustin Tobler, Aug 20, 2025
  4. 3/3 bulk-checkin: wire repository variableJustin Tobler, Aug 20, 2025
  5. Junio C HamanoAug 21, 2025
  6. Justin ToblerAug 21, 2025
  7. Junio C HamanoAug 21, 2025
  8. Junio C HamanoAug 21, 2025
  9. 0/4 bulk-checkin: remove global transaction stateJustin Tobler, Aug 21, 2025
  10. 1/4 bulk-checkin: introduce object database transaction structureJustin Tobler, Aug 21, 2025
  11. 3/4 bulk-checkin: require transaction for index_blob_bulk_checkin()Justin Tobler, Aug 21, 2025
  12. Junio C HamanoAug 22, 2025
  13. Justin ToblerAug 22, 2025
  14. Junio C HamanoAug 22, 2025
  15. 2/4 bulk-checkin: remove global transaction stateJustin Tobler, Aug 21, 2025
  16. Junio C HamanoAug 22, 2025
  17. Justin ToblerAug 22, 2025
  18. Junio C HamanoAug 22, 2025
  19. 4/4 bulk-checkin: use repository variable from transactionJustin Tobler, Aug 21, 2025
  20. Junio C HamanoAug 22, 2025
  21. Justin ToblerAug 22, 2025
  22. 0/4 bulk-checkin: remove global transaction stateJustin Tobler, Aug 22, 2025
  23. 1/4 bulk-checkin: introduce object database transaction structureJustin Tobler, Aug 22, 2025
  24. 2/4 bulk-checkin: remove global transaction stateJustin Tobler, Aug 22, 2025
  25. 3/4 bulk-checkin: require transaction for index_blob_bulk_checkin()Justin Tobler, Aug 22, 2025
  26. 4/4 bulk-checkin: use repository variable from transactionJustin Tobler, Aug 22, 2025
  27. Junio C HamanoAug 25, 2025

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.