{"thread":{"id":"66854","subject":"[BUG] partial clone lazy-fetches a blob it just wrote (bisected to 5946a564cd)","startedAt":"2026-11-16T11:45:52Z","lastAt":"2026-11-16T20:16:05Z","messageCount":3,"participants":["Google — Mergify","Patrick Steinhardt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"558532","messageId":"69EF6B53-E153-46CC-B7EC-536BEBE8CF52@mergify.com","threadId":"66854","inReplyTo":null,"subject":"[BUG] partial clone lazy-fetches a blob it just wrote (bisected to 5946a564cd)","fromName":"Google — Mergify","fromEmail":"remy.duthu@mergify.com","sentAt":"2026-11-16T11:45:52Z","receivedAt":"2026-11-16T11:45:52Z","isPatch":false,"sender":{"key":"remy.duthu@mergify.com","avatar":null},"body":"Since Git 2.54.0, a cherry-pick in a blob:none partial clone can try to\nlazy-fetch a blob that the cherry-pick has just written to the local\nobject store. The server never had that blob, so the fetch fails and the\ncommand dies:\n\n  Auto-merging dev-tools/go.mod\n  Auto-merging go.mod\n  Auto-merging testing/go.mod\n  [bp fatal: remote error: upload-pack: not our ref 201d4490be49318c26485d10869070ae44d3e7ef\n  fatal: could not fetch 929ed29a43110d65cb7d581c4028e3f183088c3c from promisor remote\n\nThe commit itself has been written. The failure happens while the commit\nsummary is printed. 201d4490 is the result of the content merge of\ndev-tools/go.mod. It is stored as a loose object in the clone, and\n\"git cat-file -t\" with GIT_NO_LAZY_FETCH=1 reports it as a blob after\nthe failure.\n\nReproduction (needs network access to github.com, takes a few seconds):\n\n  git init -q repro && cd repro\n  git config core.repositoryformatversion 1\n  git config user.name t && git config user.email t@example.com\n  git remote add origin https://github.com/elastic/fleet-server\n  git config remote.origin.promisor true\n  git config remote.origin.partialclonefilter blob:none\n  git sparse-checkout set --no-cone --stdin </dev/null\n  git fetch --quiet --no-tags --depth=2 origin \\\n    +refs/heads/9.4:refs/remotes/origin/9.4 \\\n    8e9bf0673fe59a12c889b0c087319077c4138103\n  git checkout --quiet -b bp origin/9.4\n  git cherry-pick -x 8e9bf0673fe59a12c889b0c087319077c4138103\n\nThe 9.4 branch moves over time, so the exact object ids may change, but\nthe shape of the failure should not.\n\nResults:\n\n  - Fails on 2.54.0, 2.55.0, 2.56.0, 2.56.1 and master (7fb6055e67).\n  - Succeeds on 2.47.3, 2.48.1, 2.50.1, 2.52.0 and 2.53.0.\n  - \"git bisect\" between v2.53.0 and v2.54.0 names:\n      5946a564cd odb/source: make `read_object_info()` function pluggable\n\nMy reading of that commit: before it, a lookup miss without\nOBJECT_INFO_QUICK called odb_reprepare(), which also dropped the loose\nobject cache. Since then, the second read flushes only the packfile\nstore. The loose object cache is filled per fan-out directory and is\nnot updated when an object is written. So once a directory has been\nscanned, a loose object written into it afterwards stays invisible to\nOBJECT_INFO_QUICK lookups such as the OBJECT_INFO_FOR_PREFETCH check\nin the diff prefetch. git then puts that object in the promisor fetch.\nIn the case above, the base blob of dev-tools/go.mod (2070e6a...) and the\nmerged blob (201d449...) share the \"20/\" directory, which fits.\n\nTo check this, I applied the change below on master. With it, the\nreproduction succeeds:\n\n--- a/odb/source-files.c\n+++ b/odb/source-files.c\n@@ static enum odb_read_status odb_source_files_read_object_info(\n \tfor (struct odb_files_dir *dir = files->dirs; dir; dir = dir->next) {\n-\t\tif (retry)\n+\t\tif (retry) {\n \t\t\todb_source_prepare(&dir->packed->base, ODB_PREPARE_FLUSH_CACHES);\n+\t\t\todb_source_prepare(&dir->loose->base, ODB_PREPARE_FLUSH_CACHES);\n+\t\t}\n\nThis is a check, not a proposed fix. Updating the loose cache when an\nobject is written may be the better fix. I'm happy to test patches\nagainst this reproduction.\n\nWe run git this way in production (blob:none partial clones,\ncherry-pick, merge-tree). This hit cherry-picks in several unrelated\npublic and private repositories, and on each repository it fails the\nsame way on every attempt. We have gone back to 2.53 until this is\nfixed.\n\n\n"},{"id":"558533","messageId":"avr7CP29sPOdS5DE@pks.im","threadId":"66854","inReplyTo":"69EF6B53-E153-46CC-B7EC-536BEBE8CF52@mergify.com","subject":"Re: [BUG] partial clone lazy-fetches a blob it just wrote (bisected to 5946a564cd)","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-16T12:46:00Z","receivedAt":"2026-11-16T12:46:00Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\nOn Mon, Nov 16, 2026 at 12:45:52PM +0100, Google — Mergify wrote:\n> Since Git 2.54.0, a cherry-pick in a blob:none partial clone can try to\n> lazy-fetch a blob that the cherry-pick has just written to the local\n> object store. The server never had that blob, so the fetch fails and the\n> command dies:\n\nI think this is a known issue and there's a fix in-flight at [1]. Could\nyou please test that change and verify that it fixes the issue for you?\n\nThanks!\n\nPatrick\n\n[1]: <20261104-pks-odb-loose-stale-cache-v1-0-a00d5cdb5e7d@pks.im>\n\n"},{"id":"558574","messageId":"avtkhTVuKlnAugZQ@pks.im","threadId":"66854","inReplyTo":"8F838F35-E5D5-4F6C-8835-99D1C040E0D4@mergify.com","subject":"Re: [BUG] partial clone lazy-fetches a blob it just wrote (bisected to 5946a564cd)","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-16T20:16:05Z","receivedAt":"2026-11-16T20:16:05Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Hi,\n\n[Re-adding the Git mailing list.]\n\nOn Mon, Nov 16, 2026 at 01:58:04PM +0100, Google — Mergify wrote:\n> Hi Patrick,\n> \n> > I think this is a known issue and there's a fix in-flight at [1]. Could\n> > you please test that change and verify that it fixes the issue for you?\n> \n> \n> Yes, it fixes it. I applied both patches on master (7fb6055e67) and ran the\n> reproduction from my report against each build:\n> \n>   - master: fails with \"not our ref 201d4490...\" as before.\n>   - master + the two patches: the cherry-pick succeeds.\n> \n> My test passes with the series applied, including the new \"merge does not\n> lazy-fetch locally written objects\" test.\n\nThanks for confirming!\n\nPatrick\n\n"}]}