From: Justin Tobler <jltobler@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Wolfgang Kritzinger <wkritzinger@atlassian.com>
Subject: Re: [PATCH v2 5/6] odb: don't try re-fetching corrupt objects
Date: Wed, 14 Oct 2026 10:59:38 -0500 [thread overview]
Message-ID: <as-jctNq5uxGRAx9@denethor> (raw)
In-Reply-To: <20261014-pks-odb-files-alternates-cleanups-v2-5-fed9b2caa3be@pks.im>
On 26/10/14 10:53AM, Patrick Steinhardt wrote:
> When we failed reading an object in a repository with a promisor remote
> we try to fetch it from the promisor and then re-read it. This logic
> kicks in not only when the object couldn't be found, but also in the
> case where it could be found but the object is corrupt. It feels dubious
> though to just paper over corruption and proceed as if nothing has
> happened, happily fetching data from the promisor.
Agreed. If we know the object is corrupt, it makes sense to stop early
and report the finding.
> Adapt the code so that we only fetch objects in case they are missing.
>
> Suggested-by: Justin Tobler <jltobler@gmail.com>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> odb.c | 28 ++++++++--------------------
> 1 file changed, 8 insertions(+), 20 deletions(-)
>
> diff --git a/odb.c b/odb.c
> index 095183aec0..2c93a9490c 100644
> --- a/odb.c
> +++ b/odb.c
> @@ -265,7 +265,6 @@ static enum odb_read_status do_oid_object_info_extended(struct object_database *
> struct strbuf corrupt_err = STRBUF_INIT;
> const struct object_id *real = oid;
> enum odb_read_status ret;
> - bool corrupt = false;
>
> if (flags & OBJECT_INFO_LOOKUP_REPLACE)
> real = lookup_replace_object(odb->repo, oid);
> @@ -278,38 +277,27 @@ static enum odb_read_status do_oid_object_info_extended(struct object_database *
>
> ret = odb_source_read_object_info(odb->source, real, oi, flags,
> &corrupt_err);
> - if (!ret)
> - goto out;
> - if (ret != ODB_READ_NOT_FOUND)
> - corrupt = true;
> -
> - /* Try to fetch the missing object from a promisor remote. */
> - if (odb->repo->fetch_if_missing && repo_has_promisor_remote(odb->repo) &&
> - !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) {
> + if (ret == ODB_READ_NOT_FOUND &&
> + odb->repo->fetch_if_missing &&
> + !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT) &&
> + repo_has_promisor_remote(odb->repo)) {
Ok, now we only try to fetch a missing object specifically if it was
ODB_READ_NOT_FOUND in the first lookup. This means we now skip this
logic if the object is corrupt. This makes more sense to me and looks
good.
> + /* Try to fetch the missing object from a promisor remote. */
> promisor_remote_get_direct(odb->repo, real, 1);
> -
> ret = odb_source_read_object_info(odb->source, real, oi, flags,
> - corrupt_err.len ? NULL : &corrupt_err);
> - if (!ret)
> - goto out;
> - if (ret != ODB_READ_NOT_FOUND)
> - corrupt = true;
> + &corrupt_err);
> }
>
> - if (flags & OBJECT_INFO_DIE_IF_CORRUPT) {
> + if (ret < 0 && (flags & OBJECT_INFO_DIE_IF_CORRUPT)) {
> if ((flags & OBJECT_INFO_LOOKUP_REPLACE) && !oideq(real, oid))
> die(_("replacement %s not found for %s"),
> oid_to_hex(real), oid_to_hex(oid));
> - if (corrupt) {
> + if (ret != ODB_READ_NOT_FOUND) {
> if (corrupt_err.len)
> die("%s", corrupt_err.buf);
> die(_("object %s is corrupt"), oid_to_hex(real));
> }
> }
>
> - ret = corrupt ? ODB_READ_ERROR : ODB_READ_NOT_FOUND;
> -
> -out:
The remainder of this patch is functionally identical and looks good.
-Justin
next prev parent reply other threads:[~2026-10-14 15:59 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 7:36 [PATCH 0/5] odb/files: cleanups and improvements for alternates Patrick Steinhardt
2026-10-13 7:36 ` [PATCH 1/5] odb/source-files: fix performance when reading objects with alternates Patrick Steinhardt
2026-10-13 20:46 ` Justin Tobler
2026-10-13 7:36 ` [PATCH 2/5] odb/source-files: fix performance when streaming " Patrick Steinhardt
2026-10-13 20:51 ` Justin Tobler
2026-10-13 7:36 ` [PATCH 3/5] odb/source-files: make the second read an implementation detail Patrick Steinhardt
2026-10-13 21:28 ` Justin Tobler
2026-10-14 6:55 ` Patrick Steinhardt
2026-10-14 15:37 ` Justin Tobler
2026-10-13 7:36 ` [PATCH 4/5] odb: remove read loop for found objects Patrick Steinhardt
2026-10-13 21:48 ` Justin Tobler
2026-10-14 6:56 ` Patrick Steinhardt
2026-10-14 15:38 ` Justin Tobler
2026-10-13 7:36 ` [PATCH 5/5] odb/source: drop `local` flag Patrick Steinhardt
2026-10-13 22:44 ` Justin Tobler
2026-10-14 6:56 ` Patrick Steinhardt
2026-10-14 15:43 ` Justin Tobler
2026-10-14 8:53 ` [PATCH v2 0/6] odb/files: cleanups and improvements for alternates Patrick Steinhardt
2026-10-14 8:53 ` [PATCH v2 1/6] odb/source-files: fix performance when reading objects with alternates Patrick Steinhardt
2026-10-14 13:35 ` Johannes Schindelin
2026-10-14 13:44 ` Patrick Steinhardt
2026-10-14 8:53 ` [PATCH v2 2/6] odb/source-files: fix performance when streaming " Patrick Steinhardt
2026-10-14 8:53 ` [PATCH v2 3/6] odb/source-files: make the second read an implementation detail Patrick Steinhardt
2026-10-14 8:53 ` [PATCH v2 4/6] odb: remove read loop for found objects Patrick Steinhardt
2026-10-14 8:53 ` [PATCH v2 5/6] odb: don't try re-fetching corrupt objects Patrick Steinhardt
2026-10-14 15:59 ` Justin Tobler [this message]
2026-10-14 8:53 ` [PATCH v2 6/6] odb/source: drop `local` flag Patrick Steinhardt
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=as-jctNq5uxGRAx9@denethor \
--to=jltobler@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
--cc=wkritzinger@atlassian.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.