Skip to content

refactor(core): remove dead per-store WAL cleanup timer - #166

Merged
beinan merged 2 commits into
mainfrom
remove-dead-cleanup-timer
Jul 22, 2026
Merged

refactor(core): remove dead per-store WAL cleanup timer#166
beinan merged 2 commits into
mainfrom
remove-dead-cleanup-timer

Conversation

@beinan

@beinan beinan commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • RolloutStore::spawn_periodic_cleanup and its cleanup_interval_secs option/field had no production caller. WAL merge is driven by two live paths instead: the server's process-wide spawn_global_sweeper and the master's fan-out MergeWal sweep (feat(master): auto-sweep MergeWal from pending WAL generations #162), both calling cleanup_own_shard directly.
  • Removes the per-store timer, its RolloutStoreOptions.cleanup_interval_secs option and the store field, the two dead tests, and stale doc/comment references. This eliminates a confusing third WAL-scheduling path.
  • The server-level rollout_cleanup_interval_secs (which drives the active global sweeper) is retained unchanged.

Net: 5 insertions, 220 deletions.

Test plan

  • cargo build -p lance-context-core -p lance-context-server -p lance-context
  • cargo test -p lance-context-core rollout (27 passed)
  • cargo clippy clean on all three crates
  • cargo fmt --all

🤖 Generated with Claude Code

`RolloutStore::spawn_periodic_cleanup` (and its `cleanup_interval_secs`
option/field) had no production caller: WAL merge is now driven by the
server's process-wide `spawn_global_sweeper` and the master's fan-out
`MergeWal` sweep, both of which call `cleanup_own_shard` directly. Drop
the per-store timer, its option/field, and its two tests to remove a
confusing third scheduling path. The server-level
`rollout_cleanup_interval_secs` (driving the active global sweeper) is
retained.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
beinan added a commit that referenced this pull request Jul 22, 2026
…#168)

## Summary
- `AppError::from_lance` took `impl Display` and string-matched the
rendered message (`"not found"`, `"Invalid"`, `"DatasetNotFound"`). That
is brittle (breaks on any Display wording change) and over-broad (any
message containing `"Invalid"` — e.g. `InvalidTableLocation`,
`InvalidRef` — became a 400).
- Now takes `lance::Error` by value (re-exported as `LanceError` from
`lance-context-core`) and matches **typed variants**:
`DatasetNotFound`/`NotFound` → 404, `DatasetAlreadyExists` → 409,
`InvalidInput`/`SchemaMismatch` → 400, else 500.
- The one signal Lance exposes no dedicated variant for — "compaction
already in progress", raised as an `ArrowError::InvalidArgumentError`
folded into Lance's generic `Arrow` variant — is still matched by text,
but checked **up front** so it keeps mapping to 409
`COMPACTION_IN_PROGRESS`.
- All call sites already passed `lance::Error`, so no caller changes
were needed.

## Test plan
- [x] `cargo test -p lance-context-server error::` (typed-variant
mapping + Arrow-wrapped compaction case)
- [x] `cargo clippy -p lance-context-server -p lance-context-core` clean
- [x] `cargo fmt --all`

Independent of #166 and #167.

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

Co-authored-by: Claude Opus 4 <noreply@anthropic.com>
beinan added a commit that referenced this pull request Jul 22, 2026
## Summary
- `ShardWriter` has no `Drop`, so its background tasks are only
reclaimed by an explicit `close().await`. At process shutdown the
runtime is about to stop, so the detached best-effort close in
`RolloutStore::Drop` may never run — leaking those tasks / skipping a
clean drain.
- Adds `AppState::shutdown()`, which snapshots the resident LRU and
awaits `RolloutStore::close()` on each handle. Wired into `main` right
after `axum::serve(...).with_graceful_shutdown(...)` returns
(connections already drained). Idempotent and a no-op on an empty cache.

## Test plan
- [x] `cargo test -p lance-context-server state::` (incl. new
`shutdown_closes_resident_writers`)
- [x] `cargo clippy -p lance-context-server` clean
- [x] `cargo fmt --all`

Note: this branch is independent of #166; it does not touch the
`cleanup_interval_secs` removal.

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

Co-authored-by: Claude Opus 4 <noreply@anthropic.com>
Removing the `cleanup_interval_secs` field left several test
`RolloutStoreOptions` literals specifying all remaining fields, so the
trailing `..Default::default()` became redundant and tripped
`clippy::needless_update` under `--all-targets` (CI runs
`clippy --workspace --all-targets -- -D warnings`).

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@beinan
beinan merged commit 0bf8f9b into main Jul 22, 2026
9 checks passed
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.

2 participants