Persist resurrected tasks as new tasks (#98729)
### What? Ensure a GC-resurrected persistent task is persisted again as a new task. This is the final layer in stack #98709 and depends on the restore-waiter lifetime fix in #98728. ### Why? GC soft-deletes a disconnected task, then the following snapshot persists a tombstone that removes its durable task record and task-type lookup entry. Normal operations resume after the snapshot's logical state is frozen, so a concurrent connection can still find the resident soft-deleted task and resurrect it before post-snapshot eviction removes the in-memory entry. Resurrection already cleared `deleted`, marked the task dirty, and scheduled recomputation. It did not, however, mark the task as newly publishable. If the tombstone had already committed, later snapshots could persist recomputed data without re-establishing the complete persistent identity of the resurrected task. Once in-memory cache state was evicted, future lookups could no longer recover that otherwise-live task by type. A resident deleted task is guaranteed to retain its type: GC restores all categories before marking it deleted, and post-snapshot eviction handles deleted tasks by removing the whole entry rather than partially dropping the type. ### How? When the connect handshake wins the resurrection race, mark the task as `new_task` again and mark its Data category modified. The next snapshot therefore persists it using the normal new-task path, including recreating its task-type lookup entry and the Data record used to verify that lookup. The task remains dirty so its cells and graph edges are rebuilt through the existing recomputation path. The update is unconditional for a resident deleted task; a missing type remains an invariant violation rather than being silently skipped. ### Verification - Top-of-stack stress: 0 failures across 1,200 runs using 8 parallel workers - Sequential stress: 0 failures across 150 runs - `cargo test -p turbo-tasks-backend --lib` (102 passed) - `cargo test -p turbo-tasks-backend --test eviction --test gc_resurrection --test gc_collection --test gc_interrupt --test gc_stress` (19 passed) - `cargo fmt -- --check` - `cargo clippy -p turbo-tasks-backend --tests -- -D warnings` Depends on #98728. <!-- NEXT_JS_LLM --> <!-- fleet 6aa6acec-6286-4b03-86f4-13f4c7e2b2fa --> Co-authored-by:vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by:
Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
Showing
Please
register
or
sign in
to comment