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

Re: [PATCH v2 5/6] odb: don't try re-fetching corrupt objects

From
Justin Tobler <jltobler@gmail.com>
Date
Oct 14, 2026, 15:59 UTC
Message-ID
<as-jctNq5uxGRAx9@denethor>
In-Reply-To
<20261014-pks-odb-files-alternates-cleanups-v2-5-fed9b2caa3be@pks.im>
On 26/10/14 10:53AM, Patrick Steinhardt wrote:
Show 6 quoted lines
> 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.

Show 36 quoted lines
> 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.

Show 28 quoted lines
> +		/* 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
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 27 of 37 in “odb/files: cleanups and improvements for alternates”
  1. 0/5 odb/files: cleanups and improvements for alternatesPatrick Steinhardt, Oct 13, 2026
  2. 1/5 odb/source-files: fix performance when reading objects with alternatesPatrick Steinhardt, Oct 13, 2026
  3. Justin ToblerOct 13, 2026
  4. 2/5 odb/source-files: fix performance when streaming objects with alternatesPatrick Steinhardt, Oct 13, 2026
  5. Justin ToblerOct 13, 2026
  6. 3/5 odb/source-files: make the second read an implementation detailPatrick Steinhardt, Oct 13, 2026
  7. Justin ToblerOct 13, 2026
  8. Patrick SteinhardtOct 14, 2026
  9. Justin ToblerOct 14, 2026
  10. 4/5 odb: remove read loop for found objectsPatrick Steinhardt, Oct 13, 2026
  11. Justin ToblerOct 13, 2026
  12. Patrick SteinhardtOct 14, 2026
  13. Justin ToblerOct 14, 2026
  14. 5/5 odb/source: drop `local` flagPatrick Steinhardt, Oct 13, 2026
  15. Justin ToblerOct 13, 2026
  16. Patrick SteinhardtOct 14, 2026
  17. Justin ToblerOct 14, 2026
  18. Patrick SteinhardtOct 15, 2026
  19. 0/6 odb/files: cleanups and improvements for alternatesPatrick Steinhardt, Oct 14, 2026
  20. 1/6 odb/source-files: fix performance when reading objects with alternatesPatrick Steinhardt, Oct 14, 2026
  21. Johannes SchindelinOct 14, 2026
  22. Patrick SteinhardtOct 14, 2026
  23. 2/6 odb/source-files: fix performance when streaming objects with alternatesPatrick Steinhardt, Oct 14, 2026
  24. 3/6 odb/source-files: make the second read an implementation detailPatrick Steinhardt, Oct 14, 2026
  25. 4/6 odb: remove read loop for found objectsPatrick Steinhardt, Oct 14, 2026
  26. 5/6 odb: don't try re-fetching corrupt objectsPatrick Steinhardt, Oct 14, 2026
  27. Justin ToblerOct 14, 2026
  28. 6/6 odb/source: drop `local` flagPatrick Steinhardt, Oct 14, 2026
  29. 0/6 odb/files: cleanups and improvements for alternatesPatrick Steinhardt, Oct 15, 2026
  30. 1/6 odb/source-files: fix performance when reading objects with alternatesPatrick Steinhardt, Oct 15, 2026
  31. 2/6 odb/source-files: fix performance when streaming objects with alternatesPatrick Steinhardt, Oct 15, 2026
  32. 3/6 odb/source-files: make the second read an implementation detailPatrick Steinhardt, Oct 15, 2026
  33. 4/6 odb: remove read loop for found objectsPatrick Steinhardt, Oct 15, 2026
  34. 5/6 odb: don't try re-fetching corrupt objectsPatrick Steinhardt, Oct 15, 2026
  35. 6/6 odb/source: drop `local` flagPatrick Steinhardt, Oct 15, 2026
  36. Justin ToblerOct 15, 2026
  37. Junio C HamanoOct 16, 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.