Skip to content

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

Closed

Description

@dezren39

Evidence

On current main, EventStore::open_with runs recover_device_ops inside a write transaction during every store open (pkgs/id/crates/id-events/src/event_store/mod.rs:449-455). The one-time recovery helper in event_store/ingest.rs:140-156 collects every EVENTS row into Vec<Event> and every waiting row into another Vec<Event> before scanning. It then accumulates all missing device-op rows in a third Vec (:156, :178-185) before writing any of them. EVENTS is persistent historical state; there is no global row-count cap, and pruning is explicit (EventStore::prune_behind_cut). Thus an upgrade of a large but valid store has temporary memory proportional to its entire history while holding the startup write transaction, and can stall or OOM before the store opens.

The recovery is being added by open PR #11283 as part of #8160. That PR provides the right recovery semantics but retains this whole-store materialization; this issue tracks the independent memory-bound requirement and should be cross-linked, not treated as a duplicate.

Why it matters

A large long-lived store, especially one that has not pruned old events, can require multiple copies of its history in memory during the one-time upgrade. The failure occurs on open, so affected users may be unable to start the store to recover or prune it.

Acceptance criteria

  • Recovery scans stored and waiting rows without retaining all decoded events simultaneously; any staging is bounded by a documented fixed batch/size limit (or equivalent constant-space approach).
  • Preserve the existing verified-body check, idempotence, recovered count, and incomplete-recovery warning/report.
  • Add a test with a large synthetic legacy store that exercises recovery across multiple batches and proves every eligible operation is recovered, missing bodies are reported, and restart does not duplicate rows.
  • Keep recovery transactional or document and test a safe resumable strategy if bounded batching requires multiple transactions.

Related implementation: #11283 / #8160.

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/triageQueue packet kind: verify, reproduce, and route this item
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 17, 2026
  2. developing-today commented on Nov 17, 2026

    @developing-today
    Contributor
  3. added a commit that references this issue on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions