Repository navigation
fix(daemon): bound FTS startup probes - #1443
Conversation
Problem: live deployment showed polylogued still scanned messages_fts_docsize before binding health sockets. On the production archive a docsize count took about 19s and join probes ran beyond 30s, pushing the service into D-state and a 6G cgroup peak.\n\nWhat changed: the daemon startup path now only performs cheap structural recovery: missing FTS table, missing triggers, or completely empty message FTS while messages exist. Exact FTS freshness scans remain outside the pre-listen startup path. The run command also tolerates test/runner stderr streams without a fileno when enabling faulthandler.\n\nVerification: pytest tests/unit/daemon/test_daemon_cli.py tests/unit/daemon/test_fts_trigger_drift.py tests/unit/daemon/test_fts_global_repair.py tests/unit/daemon/test_health_contract.py tests/unit/daemon/test_daemon_status.py tests/unit/storage/test_fts_trigger_lifecycle.py tests/unit/storage/test_fts_repair_sql.py tests/unit/storage/test_fts5.py tests/unit/storage/test_fts_bloat_invariants.py tests/unit/storage/test_archive_search_contracts.py -q; devtools verify --quick.\n\nRef #1442
|
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 (2)
📝 WalkthroughWalkthroughDaemon FTS startup is simplified to avoid expensive pre-listen shadow-table scans. The targeted structural mismatch repair logic and its heavy COUNT(*) queries are removed, keeping only cheap structural checks (missing tables, missing triggers, empty FTS). A new faulthandler safe-initialization helper prevents errors when ChangesFTS Startup Bounded Repair and Faulthandler Safe Initialization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 minutes Possibly related issues
Possibly related PRs
Poem
🚥 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
polylogue/polylogue/daemon/cli.py
Lines 171 to 175 in bc47214
When startup detects missing FTS sync triggers, this path restores trigger DDL but performs no freshness repair unless the entire message FTS is empty. In the documented SIGKILL-during-bulk-suspend scenario, rows can be written while triggers are absent, leaving partial gaps in messages_fts_docsize; with a non-empty index, has_indexed_messages stays true and the daemon commits/serves stale search results indefinitely until an explicit repair is run. The removed mismatch reconciliation made this case self-healing, so this is a correctness regression for real archives that hit trigger drift.
ℹ️ 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
Keeps
polyloguedstartup bounded by removing exact message FTS shadow-table counts and gap joins from the pre-listen readiness path. Startup still repairs cheap structural hazards: missing FTS tables, missing triggers, and completely empty message FTS when messages exist.Problem
Live deployment of #1441 showed the daemon still scanning
messages_fts_docsizebefore binding HTTP sockets. On the production archive,SELECT COUNT(*) FROM messages_fts_docsizetook about 19s, the join probes exceeded 30s before manual termination, and the systemd service read ~860MB over 5s while reaching a 6G cgroup memory peak. That made restarts unobservable and hostile to the host.Closes #1442.
Solution
polylogue.daemon.cli._ensure_fts_startup_readiness.COUNT(*) FROM messages_fts_docsizeand FTS docsize join probes.faulthandler.enable()for Click test streams that do not exposefileno().Verification
pytest tests/unit/daemon/test_daemon_cli.py tests/unit/daemon/test_fts_trigger_drift.py tests/unit/daemon/test_fts_global_repair.py tests/unit/daemon/test_health_contract.py tests/unit/daemon/test_daemon_status.py tests/unit/storage/test_fts_trigger_lifecycle.py tests/unit/storage/test_fts_repair_sql.py tests/unit/storage/test_fts5.py tests/unit/storage/test_fts_bloat_invariants.py tests/unit/storage/test_archive_search_contracts.py -q→154 passed in 3.80sdevtools verify --quick→ exit_code 0, total_duration_s 45.42devtools verify --quick→ exit_code 0, total_duration_s 35.25Summary by CodeRabbit
Bug Fixes
Refactor