Skip to content

Define required mirror partial-write semantics#16

Open
jeregrine wants to merge 1 commit into
js-cleanupfrom
js-mirror-partial-write-semantics
Open

Define required mirror partial-write semantics#16
jeregrine wants to merge 1 commit into
js-cleanupfrom
js-mirror-partial-write-semantics

Conversation

@jeregrine

Copy link
Copy Markdown
Member

@chrismccord, MirrorStore writes the authoritative backend before its required mirror. If the mirror fails, it returns a plain {:error, {:mirror_failed, reason}} even though the authoritative value and ETag have already changed. Retrying with the caller's old ETag then conflicts.

This PR adds a failing integration test that demonstrates the authoritative commit and stale-ETag conflict. It intentionally does not choose a fix yet.

Which contract do you prefer?

  1. Return typed partial success containing the authoritative result and new ETag.
  2. Durably queue/repair the mirror before reporting success.
  3. Compensate or roll back the authoritative write when possible.
  4. Narrow :required semantics so this is explicitly non-atomic and callers can recover correctly.

The focused test currently fails with: ordinary mirror failure hid committed authoritative value "value-v2".

MirrorStore writes the authoritative backend before its required mirror. If the mirror rejects that write, the adapter returns a plain mirror_failed error even though the authoritative value and ETag have already changed. A caller retrying with its previous ETag then conflicts, but the error contains no indication that anything committed.\n\nAdd a deterministic integration test that records the original ETag, rejects the mirror write, proves that a retry with the old ETag conflicts, and fails because the ordinary error hid the committed authoritative value. The test is intentionally red pending a decision on the contract.\n\nPossible fixes are to return typed partial success with the authoritative result and new ETag, durably queue and repair the mirror before reporting success, compensate/roll back the authoritative write when possible, or narrow the meaning of required mode so callers do not interpret this as an atomic failure.
@jeregrine
jeregrine requested a review from chrismccord July 15, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant