next.js
0c729c51 - turbo-tasks: disable persisting after a failed snapshot (#99732)

Commit
47 days ago
turbo-tasks: disable persisting after a failed snapshot (#99732) ### What? A failed persist (the snapshot cycle returning an error or panicking) disables persisting for the rest of the session. Later persistence cycles, including the one at shutdown, are skipped: `snapshot_and_persist` returns `Ok(None)` without starting a snapshot or GC. ### Why? A failed persist leaves the task graph and the database out of sync. For example, `save_snapshot` may already have consumed `persisted_task_cache_log` entries. Persisting again after that could write inconsistent state. Split out of #99649 as requested in review. ### How? `snapshot_in_progress` (the mutex that serializes persistence cycles) now holds a `LastPersistenceStatus { Ok, Failed }`. The backend starts at `Ok`. The status is set to `Failed` before a cycle starts and reset to `Ok` only when the cycle succeeds, so a panic also leaves it `Failed` (`parking_lot` mutexes don't poison). `Failed` is sticky for the rest of the session. Treating a disabled persist as a skipped cycle means `stop` needs no separate check. The test helper skips eviction on `None`, as it does on an error. What the existing design does with tasks the failed snapshot didn't yield is unchanged. A unit test checks that a failed persist through the noop backing storage sets the status to `Failed`, and that the next persist returns `None` and leaves the task's modification for later. The panic path has no test, since that would need a backend test hook; it was checked by reading the control flow. <!-- NEXT_JS_LLM --> <!-- fleet 98a896e8-00fa-4f81-97f0-48bd49e2a9a2 --> --------- Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com> Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
Author
Parents
Loading