Skip to content

fix(daemon): skip redundant write FTS repairs - #1472

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/skip-redundant-write-fts-repair
May 24, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/skip-redundant-write-fts-repair

Conversation

@Sinity

@Sinity Sinity commented May 24, 2026

Copy link
Copy Markdown
Owner

Summary

Skip post-write message/action FTS repair when live FTS triggers were already present for the write.

Problem

After #1470 and #1471 were deployed, live validation still showed polylogued reading about 2.34 GB over 10 seconds with IO full avg10 around 20%, while logs showed hot insight rebuilds were deferred and append writes were small.

The remaining broad path was commit_archive_write_effects: it always called repair_message_fts_index_sync and repair_action_fts_index_sync for changed conversations. On normal live writes the FTS triggers already maintain those rows, so the repair did a redundant delete/reinsert of the whole conversation FTS surface after every append.

Solution

  • Record whether message/action FTS triggers were present before write side effects run.
  • Always call ensure_fts_triggers_sync to restore missing triggers.
  • If triggers were already live, trust them and skip the redundant repair.
  • If triggers were missing or suspended, keep the existing targeted repair path after trigger restoration.
  • Add tests for both paths.

This keeps the hard FTS freshness contract: live-triggered writes stay fresh immediately, and missing/suspended triggers still force repair.

Ref #1447

Verification

  • pytest -q tests/unit/archive/test_write_gateway.py tests/unit/pipeline/test_ingest_append_replay.py -> 9 passed in 0.20s
  • mypy polylogue/archive/write_effects.py tests/unit/archive/test_write_gateway.py -> Success: no issues found in 2 source files
  • devtools verify --quick -> exit_code 0, total_duration_s 39.71
  • pre-push devtools verify --quick -> exit_code 0, total_duration_s 34.62

Live deployment after the append-stats fix still showed multi-GB physical reads during tiny append batches. The write gateway was still repairing message and action FTS for every changed conversation after every write, even when live sync triggers were already present and therefore had maintained the rows.\n\nRecord whether message/action FTS triggers were live before the commit side effects run. If they were present, trust the triggers and skip the delete/reinsert repair. If any trigger was missing or suspended, keep the existing targeted repair path after ensuring triggers are restored, preserving the FTS freshness contract.\n\nFocused verification:\n- pytest -q tests/unit/archive/test_write_gateway.py tests/unit/pipeline/test_ingest_append_replay.py -> 9 passed\n- mypy polylogue/archive/write_effects.py tests/unit/archive/test_write_gateway.py -> success\n- devtools verify --quick -> exit_code 0\n\nRef #1447
@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 44 minutes and 31 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d25cb0bd-1b5b-49a0-a839-f370f097cf60

📥 Commits

Reviewing files that changed from the base of the PR and between 27c40d7 and 595fbaf.

📒 Files selected for processing (2)
  • polylogue/archive/write_effects.py
  • tests/unit/archive/test_write_gateway.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/skip-redundant-write-fts-repair

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit dae61fb into master May 24, 2026
6 checks passed
@Sinity
Sinity deleted the feature/fix/skip-redundant-write-fts-repair branch May 24, 2026 04:25
Sinity added a commit that referenced this pull request Aug 17, 2026
polylogue-gibn1, decisive: instrumented the sole consumer of
summary.fts_repair_session_ids (_commit_sync_ingest_side_effects) and it never
printed across five sessions and sixty messages in the failing
convergence-evidence test. The repair is nested inside `if transaction_started`,
so a route with an externally managed transaction skips FTS repair along with
every other post-write side effect.

Eliminated: repair_message_fts (defaults True everywhere, no daemon override),
the repair queue itself (content_changed appends unconditionally), the invariant
reader, and the triggers. Three independent places each assume another will
populate the index: replay defers the reinsert, ingest-side repair never runs,
and the path-scoped convergence check is a hardcoded `return False`.

Read the #1498 cascade retro as CLAUDE.md requires; its closed list names the
adjacent history (#1462, #1469, #1472, #1500, #1502), several of which narrowed
FTS repair to avoid redundant work. Those PR bodies are the place to start.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HWcPJJJvuF25CqVwTFgSQC
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