Skip to content

test(cleanup): pass an explicit region to the foreign root fixture - #11095

Merged
Xuanwo merged 1 commit into
mainfrom
xuanwo/fix-cleanup-foreign-root-offline
Nov 15, 2026
Merged

Xuanwo merged 1 commit into
mainfrom
xuanwo/fix-cleanup-foreign-root-offline

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 15, 2026

Copy link
Copy Markdown
Member

cleanup_reclaims_a_parent_blob_named_only_by_a_foreign_root writes through a child dataset that carries a foreign S3 base, so the managed-blob writer eagerly builds a store for that base. Without a region in the write params it discovered one with a live S3 HEAD, which timed out on the linux-arm runner and failed the test before its cleanup assertions ran (job 132721154971). The fixture now passes its existing test region and credentials through WriteParams.store_params and reuses them for the later reload; the foreign base path, branch, and the cross-root cleanup assertions are unchanged.

The test no longer needs external network access: the full cleanup module (261 tests) completes under strace with zero connect(2) calls.

The managed-blob write reloads the existing child dataset through base 7,
so the external base resolver eagerly constructs a store for that S3 base.
Without a region in the write params it discovered one with a live S3 HEAD,
which timed out on the CI runner and failed the test before its cleanup
assertions ran. Pin the fixture's existing test region and credentials in
the write params, and reuse the same options for the later reload.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions github-actions Bot added the chore label Nov 15, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

The fixture supplies the missing S3 configuration when the write opens the foreign base, preserving the cross-root cleanup assertions.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 15, 2026
@Xuanwo
Xuanwo merged commit 5806902 into main Nov 15, 2026
41 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/fix-cleanup-foreign-root-offline branch November 15, 2026 07:59
Xuanwo added a commit that referenced this pull request Nov 15, 2026
`FileFragment::storage_stats` only opened the fragment's base data
files, so the bytes a field's values occupy in data overlay files were
left out of bytes_on_disk.

Open each overlay's data file as well and add its column sizes to the
fields it holds.

### Integration verification

Integrated with main `580690261d180090bb06b010f5d11600fe09b66a`, which
carries the #11095 cleanup fixture repair; merge commit
`6fa22cbb9a4bcc91f2ee74d2202729a57182d2a7`. The feature diff is still
the same two files (+187/-6).

The regression writes two fragments with `max_rows_per_file = 2`,
overlays rows only in fragment 0, and asserts that the untouched
fragment is still counted. `id` bytes stay exactly unchanged, and `val`
bytes grow by exactly the overlay file's physical column page-buffer
bytes measured directly from its raw `FileReader` metadata.

On the combined tree: the foreign-root cleanup test with the `aws`
feature (1 passed), `dataset::statistics::tests` (2 passed),
`dataset::overlay::` (64 passed), `cargo fmt --all --check`, and `cargo
clippy --all --tests --benches -- -D warnings`.

This remains a per-fragment sum of base and overlay page-buffer bytes
for current fields. It is not logical live size or object-store
accounting, and excludes footer, manifest, deletion-file, and
Blob-sidecar bytes. Unknown and dropped fields remain excluded.

---------

Co-authored-by: Xuanwo <[email protected]>
Xuanwo added a commit to wjones127/lance that referenced this pull request Nov 15, 2026
…-verdict

Integrate the single keep/delete rule with main's bulk deletes (lance-format#10787), transaction and deletion orphan discovery (lance-format#10899) and the foreign-root fixture (lance-format#11095).
Xuanwo added a commit that referenced this pull request Nov 15, 2026
## Summary

`cleanup_file_if_not_referenced` had a separate copy of the keep/delete
rule for each file kind, and the copies had drifted. This PR splits it
into two steps that apply to every kind and are unit tested without an
object store:

```text
cleanup_file_if_not_referenced(path)
  ListedFile::classify(path)      -> (kind, FileReference) | None (unmanaged: keep)
  ReferencedFiles::contains(ref)  -> is_referenced / is_verified
  Verdict::decide(is_referenced, is_verified, maybe_in_progress) -> Keep | Delete { unverified }
```

The staging-manifest authority check is now the only per-kind special
case. The new code lives in `cleanup/file_verdict.rs`.

This also fixes the `unverified` drift. A data, index, deletion or
`_fri` file that is old and also referenced by an expiring manifest was
reported as `unverified: true` in `explain()`, and the audit log
recorded it as `delete_unverified`. It now reports as verified, which is
what transaction and `_blobs` files already did. Deletions are
unchanged: the same files get deleted either way.

## Evidence

The new unit tests are tables over path × reference state × age: 27
cases for `classify`, 7 for `decide`, and 18 for key lookup. The
`decide::verified_old` case is the regression test for the drift.

Seven integration tests only checked this rule, so they are removed:
- `cleanup_unreferenced_data_files`
- `do_not_cleanup_newer_data`
- `cleanup_old_index`
- `clean_old_delete_files`
- `dont_clean_index_data_files`
- `dont_cleanup_in_progress_write`
- `orphan_map_ages_out`

Their keep-side checks moved into
`every_removed_file_kind_contributes_its_bytes`, renamed to
`cleanup_keeps_and_removes_every_file_kind`. It now asserts exact
removed and surviving counts for every kind, so a mismatch between the
keys manifests record and the keys `classify` derives from paths is
still caught end to end.

Per-test time from `--test-threads=1 --report-time`, debug build,
measured before the current-`main` integration:

| | Tests | Time |
|---|---|---|
| Rule tests before (8 integration) | 8 | 0.187 s |
| Rule tests after (1 integration + 52 unit) | 53 | 0.075 s |
| Whole `dataset::cleanup` suite, sum of per-test times | 233 → 278 |
8.96 s → 8.85 s |

The rule tests now take 60% less time, but they were already cheap. Over
the whole suite the saving is within run-to-run noise. Most of the
suite's time goes to `branch_lineage` tests (~4.4 s), which this rule
doesn't affect. Parallel wall time is unchanged at about 1.8 s.

## Integration

Merged `main` at `57bd7ff59` with no conflicts, so the rule runs on top
of the landed bulk-delete path (#10787), transaction and deletion orphan
discovery (#10899) and the foreign-root fixture (#11095); their code and
tests are unchanged. On the merged tree `cargo fmt --all --check`,
`cargo check --workspace --tests --benches --profile ci --locked`,
`cargo clippy --all --tests --benches --profile ci --locked -- -D
warnings` and `cargo test --workspace --profile ci --locked` (23,129
passed, 0 failed) pass, as do the 52 rule cases in isolation and
`cleanup_keeps_and_removes_every_file_kind` with its exact per-kind
counts. The timings above were not re-measured after the merge.

## Merge Risk

**Door:** Two-way. No format or API change. But a mistake in this code
would delete live files, and deleted files can't be recovered.
**Blast Radius:** cleanup. Only the `unverified` flag in `explain()` and
the audit-log mode change.

Fixes #10903

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Xuanwo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants