Skip to content

fix(repair): refresh planner stats before raw replay - #3270

Merged
Sinity merged 2 commits into
masterfrom
feature/fix/raw-materialization-planner-refresh
Jul 23, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/fix/raw-materialization-planner-refresh

Conversation

@Sinity

@Sinity Sinity commented Jul 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refresh SQLite statistics for the writer-hot blocks table before a bounded raw-materialization replay.

Problem

An interrupted index-generation transition left the live raw replay path without representative planner statistics. SQLite chose an archive-wide action-pair scan for each session replacement, producing sustained multi-gigabyte reads without a plan receipt.

Solution

Run ANALYZE blocks before selected authority components are replayed. This restores the existing session-scoped planner invariant without changing source authority or durable replay semantics.

Verification

Focused planner and fixed-point tests passed: 3 passed, 63 deselected.

Ref polylogue-t93b

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of raw materialization repair by refreshing database planning statistics before replay.
    • Reduced the likelihood of delays or lock-related failures during repair operations.

Problem: interrupted index-generation transitions can leave SQLite\nwithout representative blocks statistics, causing session-scoped action\npair refreshes to scan the archive on every replay.\n\nWhat changed: analyze the writer-hot blocks table before a bounded\nraw-materialization pass so the existing session-scoped plan invariant\nis restored before any authority component is applied.\n\nCo-Authored-By: Codex <[email protected]>
@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@Sinity, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 55 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ec9318d9-7150-4982-950c-668b5a9e3a36

📥 Commits

Reviewing files that changed from the base of the PR and between 402acb1 and 5daaab9.

📒 Files selected for processing (1)
  • polylogue/storage/repair.py
📝 Walkthrough

Walkthrough

repair_raw_materialization now refreshes planner statistics in index.db before replaying executable raw materialization components.

Changes

Raw materialization repair

Layer / File(s) Summary
Planner statistics refresh
polylogue/storage/repair.py
Opens index.db with a 60-second timeout, sets busy_timeout, runs ANALYZE blocks, commits, and then continues the existing replay flow.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: refreshing planner stats before raw replay.
Description check ✅ Passed The description covers Summary, Problem, Solution, and Verification, and the omitted sections are not required here.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/raw-materialization-planner-refresh

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 402acb18d3

ℹ️ 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".

Comment thread polylogue/storage/repair.py Resolved
Preserve bootstrap statistics when a raw replay begins before blocks\nhas any measured rows, while refreshing measured statistics for populated\nindex tiers.\n\nCo-Authored-By: Codex <[email protected]>
@Sinity
Sinity merged commit e18a28b into master Jul 23, 2026
3 checks passed
@Sinity
Sinity deleted the feature/fix/raw-materialization-planner-refresh branch July 23, 2026 10:51
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

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.

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