Skip to content

moonpool-journal: save_meta can leave both copies at one generation with different payloads #304

Closed

Description

@PierreZ

Downstream: PierreZ/paros#176; paros keeps its promised ballot in the metadata, and its audit asserts the promise never decreases across a restart. References: moonpool 9ed1360, paros f2b2502.

Downstream evidence. DualFile::store computes generation + 1, writes copy 0 then copy 1, and bumps self.generation only after both succeeded (crates/moonpool-journal/src/dual.rs:125-139). store_copy can fail after its rename, on the directory sync (dual.rs:170-176), and save_meta neither poisons nor checks the poison flag. So:

  1. save_meta(A): copy 0 and copy 1 both land at generation g+1 with A; copy 1's sync_dir fails; generation stays g.
  2. The caller retries with a newer value: save_meta(B) writes copy 0 at g+1 with B, then crashes before copy 1.
  3. load finds two valid copies at g+1; max_by_key returns the last maximum, copy 1, and the journal reports A (dual.rs:93-97), silently, with meta_repaired false.

For paros A is an older promise than B: a promise rolled back by the store, which is the one thing the two-copy scheme exists to prevent. With sync_failure_probability in the random profile the sequence is reachable; the crash loop checks that the loaded metadata is the acknowledged value or the in-flight one (tests/journal.rs:1091-1168), which this violates, but it never retries a failed save_meta.

Smallest change. Bump self.generation before writing the first copy (an uncommitted generation is harmless: load takes the newest valid copy), and make load treat two valid copies with equal generation and different payloads as MetadataCorrupt rather than picking one. Optionally poison on a failed save_meta like the log does, so the caller reopens.

Determinism. No new draws.

Acceptance (crates/moonpool-journal/tests/journal.rs): inject a directory-sync failure on copy 1's rename, retry with a new payload, crash before copy 1, reopen: the newer payload is loaded. Red today. The crash loop's write plan retries a failed save_meta with a fresh value under sync_failure_probability > 0, with the existing metadata oracle.

Activity

  1. added 2 commits that reference this issue on Oct 6, 2026
    605a2e3
    31d3ac4
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