From: Aman Ganapathy <amanganapathy@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, John Cai <johncai86@gmail.com>
Subject: Re: [PATCH] reftable/writer: fsync table after writing its footer
Date: Fri, 4 Dec 2026 10:25:35 -0800 [thread overview]
Message-ID: <20261204182535.76118-1-amanganapathy@gmail.com> (raw)
In-Reply-To: <axJjW4vzZnafA_z-@pks.im>
On Fri, Dec 04, 2026 at 07:53:15AM +0100, Patrick Steinhardt wrote:
> This failure mode is quite surprising. I would have expected that we die
> with a lot of noise and refuse to do anything in case the reftable stack
> is corrupt. Did you by any chance also investigate why that's the case?
I hadn't yet, so I traced a path through the code now. As I see it, the
stack fails to load in reftable_be_init(), which saves the error in
refs->err and doesn't print anything. Every ref read after that fails,
but the error gets lost on the way up.
If you look up a single ref, refs_resolve_ref_unsafe() just returns NULL,
which is the same as when the ref doesn't exist. So "git rev-parse HEAD"
says "unknown revision", like in an empty repo.
If you list refs, the error does come back, but for-each-ref and gc don't
check it. So for-each-ref prints nothing, and gc thinks nothing is
reachable and prunes everything.
You can see it by cutting the footer off the newest table:
git init -q --ref-format=reftable repo && cd repo
git commit -q --allow-empty -m one
t=.git/reftable/$(tail -1 .git/reftable/tables.list)
truncate -s -68 "$t"
git rev-parse HEAD # "unknown revision"
git for-each-ref # prints nothing, exits 0
With the files backend, a truncated packed-refs dies right away with
"unterminated line in .git/packed-refs", so I'd expect the same here.
Should reftable_be_init() just die when the stack is corrupt, or is there
a reason the error is kept for later? Happy to send a patch for it if
need be!
Thanks for the review!
Aman
prev parent reply other threads:[~2026-12-04 18:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 2:25 [PATCH] reftable/writer: fsync table after writing its footer Aman Ganapathy
2026-12-04 6:53 ` Patrick Steinhardt
2026-12-04 18:25 ` Aman Ganapathy [this message]
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=20261204182535.76118-1-amanganapathy@gmail.com \
--to=amanganapathy@gmail.com \
--cc=git@vger.kernel.org \
--cc=johncai86@gmail.com \
--cc=ps@pks.im \
/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