From 4ac6977e4650237d79ab4385335d1a12afd9217f Mon Sep 17 00:00:00 2001 From: ScriptedAlchemy Date: Mon, 16 Nov 2026 12:55:53 -0800 Subject: [PATCH] test(code-index): pin retired pack inode in descriptor census Retention unlinks the retired pack while sibling tests open files on the same filesystem, so a reused inode number made the post-unlink holder census count an unrelated descriptor. Hold a pin on the pack for the whole test and exclude only that descriptor from the census. Co-Authored-By: Claude Opus 5.5 --- .../tests/publication_store.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/tracedecay-code-index-runtime/src/code_index_scheduler/tests/publication_store.rs b/crates/tracedecay-code-index-runtime/src/code_index_scheduler/tests/publication_store.rs index d13aba7f89..86806d3754 100644 --- a/crates/tracedecay-code-index-runtime/src/code_index_scheduler/tests/publication_store.rs +++ b/crates/tracedecay-code-index-runtime/src/code_index_scheduler/tests/publication_store.rs @@ -1924,11 +1924,17 @@ fn ordinary_retention_waits_for_active_pack_reads_and_leaves_no_idle_payload_han !expected.is_empty(), "the retired pack contains actual bytes" ); - let inode = std::fs::metadata(&path).expect("original pack inode"); + // Retention unlinks this pack while sibling tests open files on the same + // filesystem. The pin keeps the inode allocated, so its number cannot be + // reused by an unrelated descriptor; the census counts every other holder. + let pin = std::fs::File::open(&path).expect("pin the retired pack inode"); + let pin_entry = std::os::fd::AsRawFd::as_raw_fd(&pin).to_string(); + let inode = pin.metadata().expect("original pack inode"); let holders = || { std::fs::read_dir("/proc/self/fd") .expect("inspect actual process descriptor table") .filter_map(Result::ok) + .filter(|entry| entry.file_name().to_str() != Some(pin_entry.as_str())) .filter_map(|entry| std::fs::metadata(entry.path()).ok()) .filter(|metadata| metadata.dev() == inode.dev() && metadata.ino() == inode.ino()) .count() @@ -2008,11 +2014,7 @@ fn ordinary_retention_waits_for_active_pack_reads_and_leaves_no_idle_payload_han .any(|item| item.generation_id == generation_ids[0]) ); assert!(!path.exists(), "the old-only pack pathname is reclaimed"); - assert_eq!( - holders(), - 0, - "idle owners must not keep a deleted inode allocated" - ); + assert_eq!(holders(), 0, "idle owners must not hold the deleted inode"); assert!( publication .load_generation(&generation_ids[1])