Repository navigation
fix(daemon): restore all active FTS triggers - #1455
Conversation
Problem: live catch-up can suspend FTS triggers across every active search surface, but daemon recovery and health only treated messages/action-events as canonical. That left insight FTS triggers missing after recovery windows and kept readiness noisy while the archive was already under write pressure. Cursor-lag history writes also used the normal write timeout for observability-only samples, adding lock contention during ingest. What changed: centralize the FTS trigger inventory from the lifecycle module, recreate and monitor archive plus insight triggers only for active surfaces, rebuild insight FTS tables during full FTS recovery, and make cursor-lag sample/GC writes skip cleanly when SQLite is already locked. Verification: pytest tests/unit/storage/test_fts_trigger_lifecycle.py tests/unit/daemon/test_cursor_lag_integration.py tests/unit/daemon/test_fts_trigger_drift.py tests/unit/daemon/test_metrics_endpoint.py tests/unit/devtools/test_daemon_workload_probe.py -q; python -m mypy polylogue/storage/fts/fts_lifecycle.py polylogue/daemon/cursor_lag_baseline.py polylogue/daemon/health.py polylogue/daemon/metrics.py polylogue/daemon/cli.py devtools/daemon_workload_probe.py tests/unit/storage/test_fts_trigger_lifecycle.py tests/unit/daemon/test_cursor_lag_integration.py tests/unit/daemon/test_fts_trigger_drift.py; devtools verify --quick. Ref #1447
|
Caution Review failedPull request was closed or merged during review No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis PR expands the FTS (Full Text Search) trigger set from 6 to 12 canonical triggers, introduces a shared trigger names constant across daemon components, makes trigger lifecycle operations conditional on table existence, and adds database-lock resilience to cursor lag sampling. ChangesFTS Trigger Canonicalization and Conditional Lifecycle
Cursor Lag Database Lock Resilience
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ffbb36960
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
## Summary Adds process-holder diagnostics to WAL checkpoint observations so live ingest and daemon checkpoint logs can explain when SQLite checkpointing is blocked by another reader instead of silently leaving a large WAL behind. ## Problem While deploying the FTS trigger repair work from #1455, `polylogued` generated a growing WAL during catch-up and checkpointing stayed busy. The live blocker was an unrelated long-running `lynchpin.cli.current_state` process holding Polylogue database files open, but Polylogue only reported checkpoint mode/page counts. That left the operator to manually correlate `/proc`, `fuser`, and service logs. ## Solution `WalCheckpointObservation` now carries bounded `/proc` process-holder details when a checkpoint is busy, locked, or leaves the WAL above the truncate threshold. Batch ingest logs `wal_checkpoint_blocked` with the checkpoint reason, WAL sizes, busy pages, and first blockers; the daemon periodic checkpoint log includes the same blocker list. The `/proc` scan is Linux-only, bounded to active file descriptors for `polylogue.db`, `.db-wal`, and `.db-shm`, and degrades quietly when `/proc` entries vanish during iteration. Ref #1447. ## Verification - `pytest tests/unit/pipeline/test_ingest_batch_wal_checkpoint.py -q` → `2 passed in 0.08s` - `python -m mypy polylogue/storage/sqlite/wal_checkpoint.py polylogue/pipeline/services/ingest_batch/_core.py polylogue/daemon/cli.py tests/unit/pipeline/test_ingest_batch_wal_checkpoint.py` → `Success: no issues found in 4 source files` - `devtools verify --quick` → exit 0, total `38.78s`
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Restore and monitor the full active FTS trigger set during daemon startup, recovery, health checks, metrics, and workload probes. The patch also makes cursor-lag sample writes best-effort under SQLite write contention so observability does not add more pressure during catch-up.
Problem
Live deployment showed
fts_readinesserrors forsession_work_events_ftsandwork_threads_ftsmissing triggers while the daemon was also hitting SQLite lock contention. The lifecycle module knew about twelve trigger names, but restore paths recreated only the message and action-event triggers. A catch-up recovery window could therefore leave insight search surfaces stale even after the daemon believed trigger recovery had run.This is related to #1447 but does not close it: WAL growth, bounded checkpoints, and large-session memory release remain open there.
Solution
polylogue.storage.fts.fts_lifecycle.devtools daemon-workload-probeto use the same inventory.Ref #1447
Verification
pytest tests/unit/storage/test_fts_trigger_lifecycle.py tests/unit/daemon/test_cursor_lag_integration.py tests/unit/daemon/test_fts_trigger_drift.py tests/unit/daemon/test_metrics_endpoint.py tests/unit/devtools/test_daemon_workload_probe.py -q→60 passedpython -m mypy polylogue/storage/fts/fts_lifecycle.py polylogue/daemon/cursor_lag_baseline.py polylogue/daemon/health.py polylogue/daemon/metrics.py polylogue/daemon/cli.py devtools/daemon_workload_probe.py tests/unit/storage/test_fts_trigger_lifecycle.py tests/unit/daemon/test_cursor_lag_integration.py tests/unit/daemon/test_fts_trigger_drift.py→Success: no issues found in 9 source filesdevtools verify --quick→ exit0devtools verify --quick→ exit0Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Improvements