miroir/crates
jedarden 3dd63fdc67 P4.1 Rebalancer background worker with advisory lock
Implements plan §4 "Rebalancer" background task:
- Advisory lock via leader_lease (only one pod runs the rebalancer)
- Reacts to topology change events (node add/drain/fail/recover)
- Computes affected shards using the Phase 1 router
- Drives the migration state machine for each affected shard
- Updates Prometheus metrics (plan §10)
- Progress persistence via jobs table for resumability

Key features:
- Per-index leader lease scope (rebalance:<index>)
- Per-shard migration state machine with 7 phases
- Concurrency bound via max_concurrent_migrations config
- Cancellation support (pause/resume in-progress rebalancing)
- Metrics: miroir_rebalance_in_progress, documents_migrated_total, duration_seconds

Integration:
- Admin API endpoints (POST /_miroir/nodes, drain, remove) send events to worker
- Health checker syncs rebalancer metrics to Prometheus
- Worker loads persisted jobs on startup for crash recovery

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 10:51:27 -04:00
..
miroir-core P4.1 Rebalancer background worker with advisory lock 2026-05-05 10:51:27 -04:00
miroir-ctl P3: Phase 3 Task Registry + Persistence — COMPLETE 2026-05-02 16:50:42 -04:00
miroir-proxy P4.1 Rebalancer background worker with advisory lock 2026-05-05 10:51:27 -04:00