Skip to content

Backfill: page.completed recorded before persistence (crash-window data loss) #198

Description

@mcclowes

Problem

In a resumable backfill, page.completed is recorded (and the resume cursor advanced) before the page's data is persisted, so a crash in that window loses records silently.

onPage (src/interpreter/fetch-handler.ts:453-460) appends the page.completed event and advances pageProgress inside the fetch loop, while the page is still only in the in-memory allResults array. The downstream store step persists it afterwards. A crash between the final page.completed and the store's effect.applied advances pageProgress past pages that exist only in memory — on resume the fetch restarts after them and they're gone.

The page.completed docstring used to claim the data was "fetched and persisted." That's now corrected to say plainly it's fetched-only, with a pointer here (src/execution-log/events.ts).

Why it was deferred

A correct fix defers the resume-cursor advance until after the downstream store step. That restructures how backfill pagination and the store step interact (today they're decoupled — fetch accumulates all pages, then a single store step writes them), so it warrants its own change with a dedicated crash-injection test that exercises a backfill-plus-store mission. The current crash-injection suite only covers store-only missions.

See CODE_REVIEW.md (C2).

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions