]> git.ipfire.org Git - thirdparty/git.git/commit
reftable/stack: handle outdated stacks when compacting
authorPatrick Steinhardt <ps@pks.im>
Tue, 12 Aug 2025 09:54:20 +0000 (11:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 12 Aug 2025 14:41:00 +0000 (07:41 -0700)
commit54d25de3ea93d42457bfdec43949683544d0031b
treea88c2bcfb27103648413c8e62bbb35e64312248a
parent178c5885007b83dd10cac1e09b72ef8d9fe2ac29
reftable/stack: handle outdated stacks when compacting

When we compact the reftable stack we first acquire the lock for the
"tables.list" file and then reload the stack to check that it is still
up-to-date. This is done by calling `stack_uptodate()`, which knows to
return zero in case the stack is up-to-date, a positive value if it is
not and a negative error code on unexpected conditions.

We don't do proper error checking though, but instead we only check
whether the returned error code is non-zero. If so, we simply bubble it
up the calling stack, which means that callers may see an unexpected
positive value.

Fix this issue by translating to `REFTABLE_OUTDATED_ERROR` instead.
Handle this situation in `reftable_addition_commit()`, where we perform
a best-effort auto-compaction.

All other callsites of `stack_uptodate()` know to handle a positive
return value and thus don't need to be fixed.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reftable/stack.c