Skip to content

Serialize checkpoint journal transactions and add concurrent-save regression tests #2351

Open

Description

@coderabbitai

Summary

Serialize checkpoint save and journal recovery operations for the same task, and give each save a distinct transaction identity. Add deterministic regression tests for overlapping saves.

In src/core/checkpoints/index.ts, a write checkpoint reconciles and writes a pending marker before saving, then promotes and reconciles that marker after the commit. src/core/checkpoints/changeJournal.ts uses one pending marker per task. If two saves overlap, one save can replace another save's marker before reconciliation and cause a committed checkpoint's journal entry to be lost.

Overlapping checkpoint calls predate this PR. The author traced the fire-and-forget call in src/core/task/Task.ts to commit 19f306e6580ecc769ad5e2b56a97ca83447e6e53, which is an ancestor of main tip 73931fe8be. The shared pending marker and the resulting journal-entry loss are introduced by this series.

Required work

  • Choose and document the owner and scope of the serialization primitive. Consider a per-task promise chain at checkpointSave or a lock owned by the write owner. Cover the full save-and-reconcile transaction, including coordination with journal recovery, and account for old and resumed task instances sharing a task ID.
  • Define a per-save transaction identity. A single marker keyed only by task cannot distinguish concurrent transactions. Coordinate the identity and marker design with recovery of an awaiting-checkpoint intent, including how recovery distinguishes a committed save from one that did not commit.
  • Add deterministic concurrent-save regression tests with controlled interleavings. The tests must fail against the current implementation and verify that each committed save retains its own journal entries. Include overlap across old and resumed task instances and marker promotion/reconciliation; cover recovery interactions where applicable.

References

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions