Skip to content

fix: retry cleared object database pack slots#2726

Merged
Sebastian Thiel (Byron) merged 1 commit into
mainfrom
odb-fix-unreachable
Jul 19, 2026
Merged

fix: retry cleared object database pack slots#2726
Sebastian Thiel (Byron) merged 1 commit into
mainfrom
odb-fix-unreachable

Conversation

@Byron

@Byron Sebastian Thiel (Byron) commented Jul 19, 2026

Copy link
Copy Markdown
Member

Tasks

This section is for Byron only. Models continuing this PR must not add, remove, check, uncheck, rename, or reorder checkboxes here.

  • refackiew

Everything below this line was generated by Codex GPT-5.

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Fixes #2723

Summary

  • Treat cleared single-index and multi-pack-index slots as stale lookup misses instead of panicking.
  • Let the existing index refresh and object lookup retry recover transparently.
  • Add a deterministic public-API regression that reproduces the single-index panic without invoking fetch.

Reproduction

The test loads an index while leaving its pack unopened, renames the index/pack pair to model an external repack, refreshes the shared store through a second handle, and reads the same object through the stale first handle. Before the fix this panicked at the single-index cleared-slot assertion; afterward it reloads the moved index and finds the object.

Git baseline

Current git.git at a23bace963d508bd96983cc637131392d3face18 uses packfile_store_reprepare() in packfile.c to clear initialization and rescan the pack directory.

Validation

  • cargo test -p gix-odb --test odb an_object_in_a_pack_moved_by_an_external_process_can_be_found_from_a_stale_handle -- --nocapture
  • GIX_TEST_IGNORE_ARCHIVES=1 cargo test -p gix-odb
  • cargo clippy -p gix-odb --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • codex review --commit 6ae9eb1 (no findings)

The fix is very lean and updates `load_one()` to do the same as its sibling function,
which triggers a refresh of its internal index and it can recover just fine.

--- agent

Store::load_pack() assumed a non-stable handle could not retain a pack id after
its slot was cleared. Disk consolidation can move a replacement index into a
free slot without advancing the generation, leaving the old marker valid enough
to reach the cleared slot and panic.

Add a regression that loads an index without its pack, renames the index/pack
pair to model an external repack, refreshes through a second handle, and
then reads through the stale handle. This deterministically reproduced the
single-index panic without invoking fetch or needing threads.

Treat cleared slots as stale lookup misses in both single-index and
multi-pack-index paths, including the recheck under the slot lock. Existing find
logic then reloads indices and retries the object lookup.

Co-authored-by: GPT 5.6 <codex@openai.com>
@Byron
Sebastian Thiel (Byron) merged commit dca93be into main Jul 19, 2026
32 checks passed
@Byron
Sebastian Thiel (Byron) deleted the odb-fix-unreachable branch July 19, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gix_odb::Store::load_pack panics when it loads a pack slot that has been cleared by an external process

1 participant