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

Re: [PATCH v2] fetch: commit references fetched before backfilling tags

From
Karthik Nayak <karthik.188@gmail.com>
Date
Oct 15, 2026, 10:31 UTC
Message-ID
<CAOLa=ZTX16P9=Sbp3z5LpYoTzgZDb8hdk4x5xaSBbCh+dBvh4w@mail.gmail.com>
In-Reply-To
<xmqq4ieq66e8.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> Karthik Nayak <karthik.188@gmail.com> writes:
>
>> When using batched updates, the references aren't yet committed to disk
>> when we start backfilling tags. This means in situations such as shallow
>> fetching the negotiation during backfilling tags, the client doesn't
>> have any references to report in the 'have' section. Since backfilling
>> doesn't use a depth limit, this can cause the server to send all the
>> objects present in the repository.
>
> Ouch.
>
Indeed.
Show 19 quoted lines
>> Fix this by committing the previous batched update and initiating a new
>> one for backfilling tags. Also add a test which captures this regression.
>
>> @@ -2076,6 +2076,27 @@ static int do_fetch(struct transport *transport,
>>  		struct ref *tags_ref_map = NULL, **tail = &tags_ref_map;
>>
>>  		find_non_local_tags(remote_refs, transaction, &tags_ref_map, &tail);
>> +
>> +		/*
>> +		 * Backfilling tags has no depth limit. If we don't commit
>> +		 * the fetched references, the backfill will report no refs
>> +		 * in the 'have' section of the negotiation. This can cause
>> +		 * the server to send all objects.
>> +		 */
>
> Does this problem only happen when the main fetch updated some ref,
> or can backfilling make such a huge negotiation even when the main
> fetch transaction is empty?
>

Only when the main fetch updates the on-disk state. If there are no refs updated in the main transaction, then there is nothing that we could've used in the negotiation anyway.

I will modify the comment a bit, as the 'will report no refs' is a bit inaccurate, since it will only not report the refs we didn't yet commit.

Show 11 quoted lines
>> +		if (tags_ref_map && !atomic_fetch) {
>> +			retcode |= commit_ref_transaction(&transaction, false,
>> +							  transport->remote->name,
>> +							  &rejected_refs, &err);
>
> This block is entered only when "--atomic" is not in effect, because
> we want to update all refs or nothing, and these "all refs"
> presumably includes the followed tags, but does it mean those who
> want atomic fetch should be prepared to see their fetch degenerate
> down to a full clone?
>

Yes, '--atomic' always had this issue. There's not much we can do there to fix it. I will add it to my commit message though.

Show 20 quoted lines
>> +
>> +			transaction = ref_store_transaction_begin(get_main_ref_store(the_repository),
>> +								  REF_TRANSACTION_ALLOW_FAILURE, &err);
>> +			if (!transaction) {
>> +				free_refs(tags_ref_map);
>> +				retcode = -1;
>> +				goto cleanup;
>
> Is this jumping a bit too far?  If our primary fetch have finished
> successfully, and opening the next transaction only for tag backfill
> task has failed, there are tons of processing happening we skip with
> this new "goto" that we would have normally performed, starting with
> computing summary_width used for later reporting, writing out
> FETCH_HEAD, and setting upstream for the current branch, all of
> which we should be able to do as long as the primary fetch
> successfully finishes, no?
>
>> +			}
>> +		}
>

Hmm. Yeah, you have a point. I think we'll have to differentiate between `retcode` and a new `backfill_retcode`. Will add that in.

[snip]

While testing more with regards to your comments, I realized the new test doesn't really catch the issue, since we only transfer objects we already had, so checking for root_oid will fail with/without the fix. Will revert the test to the older version.

Previous: Junio C HamanoNext: Karthik Nayak
Message 8 of 36 in “fetch: commit references fetched before backfilling tags”
  1. fetch: commit references fetched before backfilling tagsKarthik Nayak, Oct 8, 2026
  2. Patrick SteinhardtOct 9, 2026
  3. Justin ToblerOct 9, 2026
  4. Karthik NayakOct 9, 2026
  5. Karthik NayakOct 9, 2026
  6. fetch: commit references fetched before backfilling tagsKarthik Nayak, Oct 12, 2026
  7. Junio C HamanoOct 12, 2026
  8. Karthik NayakOct 15, 2026
  9. fetch: commit references fetched before backfilling tagsKarthik Nayak, Oct 15, 2026
  10. Justin ToblerOct 20, 2026
  11. Patrick SteinhardtOct 21, 2026
  12. Karthik NayakOct 21, 2026
  13. Justin ToblerOct 21, 2026
  14. Karthik NayakOct 22, 2026
  15. Karthik NayakOct 21, 2026
  16. fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 22, 2026
  17. Patrick SteinhardtOct 23, 2026
  18. Karthik NayakOct 23, 2026
  19. Patrick SteinhardtOct 23, 2026
  20. Karthik NayakOct 23, 2026
  21. Karthik NayakOct 23, 2026
  22. 0/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 28, 2026
  23. 1/3 transport: add `transport_options_release()`Karthik Nayak, Oct 28, 2026
  24. Patrick SteinhardtOct 28, 2026
  25. Karthik NayakOct 28, 2026
  26. Patrick SteinhardtOct 29, 2026
  27. Karthik NayakOct 29, 2026
  28. 2/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 28, 2026
  29. 3/3 t5510: cover upstream info update on fetch failureKarthik Nayak, Oct 28, 2026
  30. Patrick SteinhardtOct 28, 2026
  31. Karthik NayakOct 28, 2026
  32. 0/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 29, 2026
  33. 1/3 t5510: cover upstream info update on fetch failureKarthik Nayak, Oct 29, 2026
  34. 2/3 transport: add `transport_options_release()`Karthik Nayak, Oct 29, 2026
  35. 3/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 29, 2026
  36. Patrick SteinhardtOct 29, 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.