git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>,
	 git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>
Subject: Re: Bug in 2.48 with `git refs migrate`
Date: Wed, 15 Jan 2025 09:07:58 -0800	[thread overview]
Message-ID: <xmqqa5bsypht.fsf@gitster.g> (raw)
In-Reply-To: <CAOLa=ZTL9n_DPhNr49XAd6bT838kc09oVx_AH7Pb4o8VK_xQ9w@mail.gmail.com> (Karthik Nayak's message of "Wed, 15 Jan 2025 11:54:51 +0000")

Karthik Nayak <karthik.188@gmail.com> writes:

> Subject: [PATCH] reftable: write correct max_update_index to header
>
> In 297c09eabb (refs: allow multiple reflog entries for the same refname,
> 2024-12-16), the reftable backend learned to handle multiple reflog
> entries within the same transaction. This was done modifying the

"done" -> "done by", I think.

> To fix the issue, the appropriate `max_update_index` limit must be set
> even before the first block is written. Add a `max_index` field to the
> transaction which holds the `max_index` within all its updates, then
> propagate this value to the reftable backend, wherein this is used to
> the set the `max_update_index` correctly.


> diff --git a/refs.c b/refs.c
> index 0f41b2fd4a..f7b6f0f897 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -1345,6 +1345,13 @@ int ref_transaction_update_reflog(struct

Not the focus of this topic/fix, but I notice that the only caller
of this ref_transaction_update_reflog() function is a static
function migrate_one_reflog_entry() in the same file.  Do we expect
that we would add more callers?  Otherwise we should make it a file
scope static and remove it from <refs.h> file.

> ref_transaction *transaction,
>  	update->flags &= ~REF_HAVE_OLD;
>  	update->index = index;
>
> +	/*
> +	 * Reference backends may need to know the max index to optimize
> +	 * their writes. So we store the max_index on the transaction level.
> +	 */
> +	if (index > transaction->max_index)
> +		transaction->max_index = index;
> +
>  	return 0;
>  }

So from the problem description, whenever we consume an index by
assigning it to an update that belongs to a transaction, we must
make sure that transaction's max_index covers that value of the
index?  I was wondering if we should have a less error prone way to
do that by having a helper function that takes ref_update and
ref_transaction objects to do the above, but this is exclusively
used by reflog migration code path and nowhere else, so it may
probably be fine as-is.  I dunno.

  reply	other threads:[~2025-01-15 17:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 13:56 Bug in 2.48 with `git refs migrate` brian m. carlson
2025-01-13 15:45 ` Patrick Steinhardt
2025-01-15 11:54 ` Karthik Nayak
2025-01-15 17:07   ` Junio C Hamano [this message]
2025-01-16  6:44     ` Karthik Nayak
2025-01-16  2:05   ` brian m. carlson
2025-01-16  7:29     ` Karthik Nayak
2025-01-16 23:21   ` brian m. carlson
2025-01-17  0:04     ` Junio C Hamano
2025-01-17  6:17       ` Karthik Nayak
2025-01-17  6:15     ` Karthik Nayak
2025-01-23 13:56   ` [PATCH v2] reftable: write correct max_update_index to header Karthik Nayak
2025-01-23 18:11     ` Junio C Hamano
2025-01-23 18:24       ` Junio C Hamano
2025-01-24 14:02         ` [PATCH v3] refs: fix uninitialized memory access of `max_index` Karthik Nayak
2025-01-24 14:46           ` Patrick Steinhardt
2025-01-24 15:48             ` Karthik Nayak
2025-01-27 10:20               ` Patrick Steinhardt
2025-01-27 16:24                 ` Junio C Hamano
2025-01-24  4:06       ` [PATCH v2] reftable: write correct max_update_index to header Karthik Nayak
2025-01-24 15:25         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqa5bsypht.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@gmail.com \
    --cc=ps@pks.im \
    --cc=sandals@crustytoothpaste.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).