Skip to content

feat(master): unified task scheduler for compaction and WAL merge#149

Merged
beinan merged 4 commits into
mainfrom
worktree-wal-merge-fix
Jul 15, 2026
Merged

feat(master): unified task scheduler for compaction and WAL merge#149
beinan merged 4 commits into
mainfrom
worktree-wal-merge-fix

Conversation

@beinan

@beinan beinan commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Generalize the master's single-serial compaction driver into a unified task scheduler running Compact and MergeWal tasks with bounded concurrency (global Semaphore) while keeping same-dataset compaction serialized via a per-name in-flight gate.
  • Add a worker endpoint POST /api/v1/internal/merge-wal/{name}; MergeWal tasks fan out to configured --worker-endpoints so each worker merges its own MemWAL shard (the master cannot fence a live writer). Tolerates 404/no-shard, fails only if every worker errors.
  • Add task queue API (POST/GET /api/v1/tasks, GET /api/v1/tasks/{id}) and a master UI Task Queue view with a "Merge WAL" action. Old compact endpoints bridge onto the new task model for backward compat.

Test plan

  • cargo test -p lance-context-api -p lance-context-server -p lance-context-master — all green (new scheduler tests: dedup, merge-wal-no-endpoints, merge-wal broadcast/sum, manual compaction)
  • cargo clippy — clean
  • npm run build (ui) — succeeds
  • Manual e2e: 2 workers + 1 master with --worker-endpoints; click Merge WAL → task Queued→Running→Done, pending_wal_generations drops to 0; multiple Compacts run at concurrency N, same-name serialized

🤖 Generated with Claude Code

beinan and others added 4 commits July 15, 2026 04:56
The periodic time-based WAL cleanup was gated by a second count
threshold (cleanup_min_generations), so "interval elapsed" would not
merge unless enough generations had also accumulated. That turned the
intended "time OR count, whichever fires first" trigger into an AND:
a shard whose interval elapsed but stayed below the count threshold
never merged.

Make the time trigger unconditional on count: cleanup_own_shard now
merges whatever is pending (>=1 generation) the moment a pass runs.
Remove the cleanup_min_generations option, the
rollout_cleanup_min_generations server config, and the
ROLLOUT_CLEANUP_MIN_GENERATIONS env/CLI flag. The count trigger
(merge_after_generations) is unchanged; the two are now a strict OR.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Generalize the master's single-serial compaction driver into a unified
task scheduler that runs Compact and MergeWal tasks with bounded
concurrency. Same-dataset compaction stays serialized via a per-name
in-flight gate; distinct experiments run concurrently under a global
semaphore. MergeWal fans out to configured worker endpoints so each
worker merges its own MemWAL shard (the master cannot fence a live
writer). Adds a task queue API + UI view and a "Merge WAL" action.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
# Conflicts:
#	crates/lance-context-master/src/routes.rs
#	crates/lance-context-master/ui/src/App.tsx
@beinan beinan merged commit 341bbba into main Jul 15, 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.

1 participant