Skip to content

fix(daemon): report WAL checkpoint blockers - #1456

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/wal-checkpoint-blockers
May 23, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/wal-checkpoint-blockers

Conversation

@Sinity

@Sinity Sinity commented May 23, 2026

Copy link
Copy Markdown
Owner

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

Problem: live catch-up can leave the archive WAL above the checkpoint threshold, but the checkpoint observation only reported busy pages. In practice the blocker can be an external reader such as a Lynchpin current-state job or stale MCP process, which makes the daemon look like the sole culprit while checkpoints cannot truncate.

What changed: record processes holding the SQLite db/wal/shm files when a checkpoint is busy, locked, or remains above the truncate threshold. Batch ingest logs the first blockers on checkpoint contention, and the periodic daemon checkpoint log includes the same blocker list.

Verification: pytest tests/unit/pipeline/test_ingest_batch_wal_checkpoint.py -q; 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; devtools verify-file-budgets; ruff check 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.

Ref #1447
@coderabbitai

coderabbitai Bot commented May 23, 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 41 minutes and 6 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: 47691075-acd2-4a9e-8a13-9c17f1714893

📥 Commits

Reviewing files that changed from the base of the PR and between 2ba4b07 and 90af707.

📒 Files selected for processing (4)
  • polylogue/daemon/cli.py
  • polylogue/pipeline/services/ingest_batch/_core.py
  • polylogue/storage/sqlite/wal_checkpoint.py
  • tests/unit/pipeline/test_ingest_batch_wal_checkpoint.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/wal-checkpoint-blockers

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 23de93f into master May 23, 2026
6 checks passed
@Sinity
Sinity deleted the feature/fix/wal-checkpoint-blockers branch May 23, 2026 23:45

@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: 90af70792a

ℹ️ 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 on lines +110 to +111
proc_root = Path("/proc")
for entry in proc_root.iterdir():

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Catch /proc scan errors when collecting blocker processes

_sqlite_file_holders iterates Path("/proc").iterdir() without a top-level OSError guard, so on non-Linux hosts (no /proc) or restricted /proc mounts this raises and escapes maybe_checkpoint_wal. Because ingest calls maybe_checkpoint_wal inside _process_ingest_batch_sync’s main try-block, that exception can fail the batch after commit-side effects instead of returning a best-effort observation; this contradicts the intended “degrades quietly” behavior for blocker diagnostics.

Useful? React with 👍 / 👎.

Comment thread polylogue/daemon/cli.py Resolved
@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.

  • 63.F040 / P2: stale at the checked revision: The daemon no longer invokes maybe_checkpoint_wal with a lost timeout argument. The periodic writer now calls the archive-wide checkpoint owner with an explicit recurring escalation at polylogue/daemon/cli.py:592-598, so the historical helper's one-second default is not the active daemon route.

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