Skip to content

fix(id-events): stream device-op recovery instead of collecting the history (#11299) - #11432

Merged
dezren39 merged 1 commit into
mainfrom
fix/11299-stream-device-op-recovery
Nov 17, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/11299-stream-device-op-recovery

Conversation

@dezren39

@dezren39 dezren39 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Closes #11299

Before: opening an event store ran recover_device_ops, which decoded every EVENTS row into a Vec<Event>, then staged every recovered device-op row in a second Vec before writing any, all inside the startup write transaction. An unpruned store needed memory proportional to its whole history just to open.

After: recovery walks EVENTS one row at a time and writes each recovered row as soon as it is found, still inside the single startup transaction. Nothing proportional to the history is held. Only the waiting rows are collected first, and the waiting pool is already capped by WaitingLimits.

How: recover_device_ops in pkgs/id/crates/id-events/src/event_store/ingest.rs now iterates the table directly and calls a new recover_one per event. The verified-body check, the recovered count, the incomplete-recovery warning and the once-only marker behave as before. One small improvement falls out: an id seen twice is now counted once, because its row exists by the second visit.

Testing: new test_open_recovers_device_operations_across_a_long_history ingests 200 grants, strips their device-op rows and 10 bodies, reopens, and checks 190 rows come back, the 10 are reported incomplete, and a forced rerun recovers 0 and adds no rows. cargo test -p id-events: 328 pass.

This is a constant-space scan in one transaction rather than batched transactions, so the transactional guarantee in the issue's last criterion holds as it did.


Generated by Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…istory (#11299)

recover_device_ops decoded every EVENTS row into a Vec, then staged
every recovered row in another Vec before writing, all inside the
startup write transaction. A large unpruned store needed memory
proportional to its whole history to open. The scan now walks EVENTS
one row at a time and writes each recovered row as it is found, in the
same transaction. Only the waiting rows are collected, and the waiting
pool is capped.

The verified-body check, the recovered count, the incomplete report and
the once-only marker are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dezren39
dezren39 marked this pull request as ready for review November 17, 2026 22:35
@dezren39
dezren39 requested a review from a team as a code owner November 17, 2026 22:35
@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@dezren39
dezren39 merged commit e2c7d79 into main Nov 17, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T22:36:57.119350Z 01c3d88 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 deleted the fix/11299-stream-device-op-recovery branch November 17, 2026 22:35
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.

fix(id-events): bound startup memory while recovering device operations

2 participants