Skip to content

feat(master): centralized serial compaction scheduler + compact routes - #138

Merged
beinan merged 1 commit into
lance-format:mainfrom
beinan:master-compaction
Jul 14, 2026
Merged

beinan merged 1 commit into
lance-format:mainfrom
beinan:master-compaction

Conversation

@beinan

@beinan beinan commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Second slice of lance-context-master. Stacked on #137 — it contains #137's commit too; review/merge #137 first, then this diff is just the scheduler.

Adds the compaction control loop:

  • Single serial driver. One background worker drains a single mpsc queue; both the periodic auto-sweep and manual API triggers push onto it, so compaction never runs two Rewrites concurrently (OCC-safe). Rewrite vs the data-plane's Append is non-conflicting, so this is safe alongside live ingest.
  • Auto-sweep (gated on compaction_interval_secs): enqueues experiments whose fragment_count >= min_fragments, honoring quiet hours.
  • Manual trigger: POST /api/v1/experiments/{name}/compact → 202 + CompactJobStatus; GET /api/v1/experiments/{name}/compact/status.
  • After a successful compaction the worker re-observes the store and bumps last_compaction / total_compactions in the stats table.

Test plan

  • manual_compaction_runs_and_updates_stats: enqueue → worker compacts → job reaches Done, stats total_compactions == 1
  • enqueue_dedupes_queued_jobs: duplicate enqueue produces a single queue message
  • cargo test / clippy / fmt green

🤖 Generated with Claude Code

Add the compaction control loop to the master. A single background worker
drains one mpsc queue, so automatic sweeps and manual API triggers share the
same serial execution path — guaranteeing a single `Rewrite` driver and no
OCC conflict. `Rewrite` vs the data-plane's `Append` is non-conflicting, so
this runs safely alongside live ingest.

- state: `compact_tx`/`compact_rx` queue + per-experiment `jobs` status map.
- scheduler: `enqueue` (de-dupes queued/running), serial worker, optional
  periodic auto-sweep gated on fragment_count >= min_fragments and quiet
  hours; post-compaction it re-observes and bumps
  last_compaction/total_compactions in the stats table.
- routes: `POST /experiments/{name}/compact` (202 + job status) and
  `GET /experiments/{name}/compact/status`.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@beinan
beinan force-pushed the master-compaction branch from 9b3a62c to d5d8684 Compare July 14, 2026 16:44
@beinan
beinan merged commit 25e3894 into lance-format:main Jul 14, 2026
9 checks passed
beinan added a commit that referenced this pull request Jul 14, 2026
…139)

## Summary
Final slice of `lance-context-master`. **Stacked on #137 + #138** — this
branch contains their commits too; review/merge #137 then #138 first,
then this diff is just the `ui/` directory.

React SPA served by the master's `ServeDir` when `--ui-dir` points at
`ui/dist`:
- **Stack**: Vite + React + TypeScript + Zustand (UI-local
search/pagination state) + TanStack Query (data).
- **Experiments table**: search by `experiment_name`, pagination,
columns for row_count / fragment_count / pending WAL gens / last_updated
/ last_compaction, inline **Compact** button that polls
`.../compact/status` until terminal.
- **Detail panel**: metric cards with on-demand `?fresh=true` recompute
+ manual compact trigger.
- `api.ts` mirrors the `lance-context-api` DTOs; `npm run build` emits
`ui/dist` (git-ignored).

## Test plan
- [x] `npm install` + `npm run build` (tsc -b && vite build) green
- [ ] Manual: run `lance-context-master --data-dir <shared> --ui-dir
crates/lance-context-master/ui/dist`, browse list/search, trigger a
compaction, watch status flip to done

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

---------

Co-authored-by: Claude Opus 4 <noreply@anthropic.com>
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.

1 participant