8000 Spike: reproduce IndexedDB flush failures on v2.0.11 and main (#894) · Issue #896 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

Spike: reproduce IndexedDB flush failures on v2.0.11 and main (#894) #896

Closed

Description

@adityamukho

Goal

Complete the v2.x triage left open in #894 with an actual browser/WASM reproduction. Keep #894 as the parent defect; this issue tracks the isolated experiment, release applicability and evidence, not a duplicate implementation.

Source evidence and limits

At main 82e1ea5e6aaf1c2760a4d59cf33db3410c49d4c3, these files have identical Git blob IDs to tag v2.0.11:

BrowserDb saves into memory and drains dirty pages before awaiting IndexedDB. Failed writes do not restore them. PersistentFactStorage appends pending fact pages, publishes the new in-memory state and clears its dirty flag before the IDB flush. A later write can therefore omit predecessor pages; checkpoint alone appears able to report success without retrying them.

The transaction wrapper listens for complete/error, not abort. The put loop propagates a synchronous exception without explicitly aborting earlier queued requests. These are source findings, not end-to-end reproduction or proof of published-package impact.

An isolated Chromium diagnostic could not start because local socket creation failed with Operation not permitted; no test assertions executed. No compiled MiniGraf browser artifact or Rust/WASM toolchain was available. Main/v2 does not have v3's explicit BrowserWriteTransaction API or deletion list; do not transfer those findings unchanged.

Experimental protocol

Use disposable database names and isolated browser profiles, never user data. Record browser/OS, core and binding revisions, package version and integrity hash, WASM build flags, commands and exact fault-injection point.

  1. Baseline: build v2.0.11 and the pinned main revision separately. Verify ordinary writes, checkpoint and reopen preserve exact query results and stored pages. Separately resolve and test a published browser package, recording its actual embedded-core provenance rather than assuming its version matches the core tag.
  2. Recoverable failure then checkpoint: persist baseline facts, then inject a recoverable IDB transaction failure after a new write's pages have been captured. Record promise settlement and in-memory visibility. With failure injection disabled, call checkpoint, reopen through a fresh handle, and compare exact state and page integrity. A closed connection alone is insufficient because later writes must be able to succeed.
  3. Failure then successful write: repeat with a later independent write. Ensure the first operation creates fact pages the successor does not rewrite; retain captured dirty-page IDs and bytes. Verify the acknowledged successor and all state it depends on after reopen. Include repeated failures.
  4. Overlap: start a successor before the failing predecessor settles. Record when each delta is captured, IDB transaction creation/order, abort/error/complete events and promise settlement. Check whether a successful successor omits predecessor pages. Do not assume restoring dirty IDs after rejection fixes an already queued delta.
  5. Abort-only settlement: separately force an abort without a request error, capture the event sequence and check that the API rejects within a bounded timeout. Include a successful-commit control. Distinguish a pending promise from a rejected flush followed by stale state.
  6. Synchronous put failure: inject a failure after at least one put is queued; inspect whether any queued writes commit despite API failure. Identify the injection as synthetic unless a realistic production trigger is established.
  7. Import and v3 comparison: test failed import followed by checkpoint/write on v2 independently. Run v3's transaction, smaller-import deletion and page-ID-reuse cases only against a separately pinned v3 build under BrowserDb (IndexedDB): a failed flush can leave the store with a meta that references missing pages #894, recording branch-specific differences. Do not infer v2 deletion behavior from v3.

Acceptance criteria

  • Reproducible scripts, raw event/page traces and a result matrix distinguish source builds from published packages and passed/failed/unrun cases.
  • Exact reopened state and page consistency are checked, not just promise resolution.
  • Sequential recovery, overlap, abort-only settlement and synchronous request exceptions have separate conclusions and controls.
  • Report confirmed affected versions and any tested workaround back to BrowserDb (IndexedDB): a failed flush can leave the store with a meta that references missing pages #894. If released-package impact is confirmed, follow CONTRIBUTING.md's known-issues process (Known issues in the current release (v2.x) #421); do not close the parent defect merely because a fix merges.
  • Any fix or backport recommendation follows the evidence; no native FinBench impact is assumed.

This is bounded browser reliability and error-path verification, consistent with PHILOSOPHY.md. No new runtime feature, dependency or file-format change is proposed.

Activity

  1. adityamukho commented on Nov 17, 2026

    @adityamukho
    CollaboratorAuthor

    Result: reproduced on main, v2.0.11 and the published @minigraf/browser@2.0.11

    Harness, raw traces and full matrix: spikes/896-idb-flush on branch spike/896-idb-flush-repro (835ffb5). It is evidence only and not for merging. Reviewed by Codex gpt-6-astra (high) over three rounds; its findings were fixed and the last round found nothing.

    Provenance. Chromium 159.0.8154.6 headless shell (Playwright 1.65.1), Linux x86_64, rustc 1.94.0, wasm-pack 0.13.1.

    • main = 19fd080a6 and v2.0.11 = 709be06c3, each built with wasm-pack build --target web --features browser. The two .wasm files are byte-identical (sha256 c4bffe16…2c76b).
    • published = npm pack @minigraf/browser@2.0.11 (integrity sha512-ycTP4OYO…pWaA==), built by minigraf-wasm 8b48111 from crates.io minigraf =2.0.11.
    • Each case ran in a fresh, disposable on-disk profile. Reopen = page reload + BrowserDb.open.

    All three builds gave the same result in all 14 cases.

    Case Faulted op After reopen
    baseline / overlap_control resolve consistent (controls)
    request-abort, then checkpoint() write rejects but stays visible in memory; checkpoint() resolves without opening an IDB transaction pre-failure state, so the handle and storage disagree
    request-abort (1 fact page), then a write rejects; successor resolves opens; acknowledged data present; the failed write's slot holds a stale old index page, and load silently takes the checksum-mismatch rebuild path
    request-abort (400 facts), then a write rejects; successor resolves [INT-052] Page 6 not found: the database does not open, so no acknowledged write can be read through a fresh handle
    overlap, 400-fact failing predecessor predecessor rejects; overlapping successor resolves INT-052
    QuotaExceededError (real, CDP quota) abort with no request error, so the promise is still pending after 5 s; next write resolves INT-052
    abort-only (synthetic) pending after 5 s stale slot, as in the 1-page case
    sync put throw (synthetic) rejects the put queued before the throw commits
    rejected importGraph memory holds the imported graph; checkpoint resolves without a write; next write resolves old data + successor write, with a header counting the imported facts

    Mechanism. After a failed flush the dirty page ids are not restored, and PersistentFactStorage has already published the new state. The next save appends after the failed write's fact pages and rewrites the index pages and header, so the new header references fact pages IndexedDB never received. If those pages fall inside the old stored range, the slots hold stale index pages and the database opens degraded. If they reach past it, the slots don't exist and open fails with INT-052.

    Second defect. transaction_to_promise uses Closure::once for onerror. Each pending request's AbortError bubbles to the transaction, so every request-abort produces FnOnce called more than once page errors (4 per 1-page failure, 35 for the 400-fact one). The promise still rejects once.

    Mitigation, tested in two cases only. Await each write before starting the next, and bound each write with a timeout. After any rejection or timeout, stop using that handle and open a fresh one before writing again. It is not shown to help overlapping writes, non-atomic failures (sync-throw), or an origin that is still full. After INT-052 the original handle (before reload) could still exportGraph(); re-import was not tested.

    Not run. v3 cases (they belong to #894 with a pinned v3 build), Firefox and WebKit, and recovery from a fresh page after INT-052. No native or FinBench impact is assumed.

    Recommendation. Fix on v3 under #894, then backport to v2.x as a data-integrity patch. The fix should do three things: settle on abort; keep failed pages dirty, or poison the handle after a failed flush, so later saves and checkpoint() cannot build on unflushed pages; and abort explicitly when a put throws. Released-package impact is confirmed, so #894 now carries known-issue and has an entry in #421.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0