Repository navigation
fix(daemon): target startup FTS gap repair - #1441
Conversation
|
Warning Review limit reached
Your plan currently allows 1 review/hour. Refill in 41 minutes and 16 seconds. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more review capacity refills, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 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: 68227a5664
ℹ️ 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".
Problem: live deployment of #1441 still showed polylogued scanning the FTS shadow tables before binding health sockets. On the production archive a docsize count took about 19s, join probes ran beyond 30s, and the daemon read hundreds of MB/s while peaking at the 6G cgroup limit. Solution: keep daemon startup to cheap structural FTS checks only: missing table, missing triggers, and completely empty message FTS while source messages exist. Exact FTS freshness scans stay out of the pre-listen path. Regression tests now reject startup COUNT/JOIN probes over messages_fts_docsize, and faulthandler setup tolerates runner streams without fileno. Verification: focused daemon/FTS pytest pack passed with 154 tests; devtools verify --quick passed locally and again in the pre-push hook. GitHub CodeQL, container builds, and GitGuardian passed. Closes #1442
|
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
Make daemon startup repair small FTS gaps by repairing only the conversations with missing message FTS rows instead of rebuilding the entire archive FTS index. Full rebuild remains for missing/empty FTS tables and structural excess-row corruption.
Problem
Live deployment of #1440 showed the daemon detecting a 56-row message FTS gap in a 3.67M-message archive and starting a full FTS rebuild before binding the HTTP health surface. That consumed ~21GB reads, ~9GB writes, peaked at the 6G memory-high boundary, left the daemon not listening on 8765/8766, and drove IO PSI severe.
Solution
Startup now distinguishes missing-row drift from structural corruption. When
messages_fts_docsizeis behindconversation_stats, it locates affectedmessages.conversation_idvalues via the missing rowids and runsrepair_message_fts_index_syncfor those conversations. Missing triggers are restored first and then flow through the same freshness repair path. Excess/stale FTS docsize rows still fall back to a full rebuild because external-content FTS rows cannot be safely deleted without the source row.Verification
pytest tests/unit/daemon/test_daemon_cli.py::test_ensure_fts_startup_readiness_uses_bounded_probes tests/unit/daemon/test_daemon_cli.py::test_ensure_fts_startup_readiness_rebuilds_empty_fts tests/unit/daemon/test_daemon_cli.py::test_ensure_fts_startup_readiness_rebuilds_stats_count_mismatch tests/unit/daemon/test_daemon_cli.py::test_ensure_fts_startup_readiness_repairs_missing_message_rows tests/unit/daemon/test_daemon_cli.py::test_ensure_fts_startup_readiness_rebuilds_when_triggers_missing tests/unit/cli/test_query_exec.py::test_query_plan_action_retrieval_lane_rejects_unready_action_read_model tests/unit/storage/test_perf_rescue_1314.py::test_search_conversation_hits_does_not_count_fts_index tests/unit/storage/test_retrieval_readiness_laws.py tests/unit/storage/test_fts5.py tests/unit/archive/test_query_search_runtime.py tests/unit/daemon/test_health_check_paths.py tests/unit/daemon/test_daemon_status.py tests/unit/daemon/test_health_contract.py::TestReadinessProbeContract tests/unit/daemon/test_fts_trigger_drift.py tests/unit/storage/test_fts_trigger_lifecycle.py tests/unit/storage/test_fts_repair_sql.py tests/unit/cli/test_insights.py::test_insights_profiles_reject_incomplete_profile_search_index tests/unit/storage/test_fts_escape_in_insights.py -q— 180 passed in 3.80sdevtools verify --quick— passed in 35.38sRef #1439