Atomicity Guarantees
This page is part of the documentation for Orleans.Lattice 10.5.0 (release line 10.5), built 2026-12-05. It is also published as markdown, with every table and list, at atomicity-guarantees.md, and llms.txt lists every page.Part of Atomic Multi-Key Writes.
This section describes the atomicity contract of the saga. For the
reader-visibility model - the per-tree transaction registry's linearization
point and how each read path consults it - see
Consistency: Atomic visibility.
The atomicity guarantee is universal: it holds within a single
tree on the local cluster and across every cluster the tree
replicates to. Receiver-side replication routes prepared writes and
the per-shard terminal mark through the same transaction-registry
linearization point used locally, so a remote reader concurrent with
replication of a SetManyAtomicAsync observes either zero or all of
the saga's keys - never a partial view (see Consistency for details).
Given a batch [(k0, v0), (k1, v1), ..., (kN-1, vN-1)], a successful
SetManyAtomicAsync call guarantees:
- All-or-nothing commit. On successful return every
kiholdsvias its last-writer-wins (LWW) value, or - if the saga failed - everykiholds the value it had before the saga started (its pre-saga value; a key that did not exist before the saga stays absent). - Sequential per-key ordering. Each key is written at most once by the saga, with a monotonically-increasing Hybrid Logical Clock timestamp. An abort issues no rollback writes - the saga's prepared writes were never visible - so a write an external writer raced in during the saga is never overwritten by a rollback.
- Crash recovery. If the silo hosting the saga grain crashes mid-flight, a keepalive reminder resumes the saga on reactivation and drives it to a terminal state (either Completed or Compensated + Completed). A saga that had already recorded its commit is completed; one that had not is compensated, because by then its caller has been answered (see Batches whose caller was answered).
- Input validation. Duplicate keys and null keys fail fast with
ArgumentExceptionbefore any write is attempted. A null value fails fast for an upsert entry, but is permitted for a delete entry in a mixed set+delete batch (a delete carries no value). An empty batch returns immediately without contacting any leaf grain. The tree's write bounds are applied up front as well, before the saga starts, so a batch they refuse stages and persists nothing: withMaxKeyLengthorMaxValueSizeBytesset, an upsert with a longer key or a larger value fails withArgumentException, and while the tree is at an enforcingMaxLiveKeysorMaxEstimatedBytescap (a best-effort check against a cached footprint) the call fails withLatticeQuotaExceededException. A delete-only batch skips the caps, because it can only shrink the tree. Delete keys are not length-checked up front: a delete key longer thanMaxKeyLengthis refused only when the saga writes the batch, so the saga aborts and the call throwsInvalidOperationException. A registeredILatticeWriteInterceptor(schema enforcement and schema versioning) also runs over the upserts up front: a transformed value is the one staged, and a value it rejects or dead-letters fails the whole call withLatticeWriteRejectedExceptionbefore the saga starts. Deletes are not intercepted. - Idempotent client retry. A re-invocation of the same saga grain (same
treeId+operationId) after successful completion returns success without re-executing. A re-invocation after a compensated-failure replays the originalInvalidOperationExceptionwith the preserved failure message. A re-invocation passes the same up-front checks as a first call, though, so they can refuse it before it reaches the saga - while the tree is at an enforcing cap, for example, the retry throwsLatticeQuotaExceededExceptioninstead of returning the original outcome.
What SetManyAtomicAsync does not guarantee
- Cross-tree atomicity (this call). A
SetManyAtomicAsynccall is bound to a single tree (ILattice) and the per-tree transaction registry is its unit of atomic visibility. To commit a batch spanning two or more distinct trees all-or-nothing, useIGrainFactory.SetManyAtomicAsync(or theBeginAtomicWritefluent builder) - a two-level saga that layers a single global decision over each tree's per-tree saga. See Cross-tree (multi-tree) atomic writes below. - Ordering across distinct sagas. Two concurrent
SetManyAtomicAsynccalls touching overlapping keys are resolved pairwise by LWW - the later HLC tick wins per key. There is no global transaction order. - Abort durability in every failure mode. If recording the abort decision or broadcasting the abort terminals fails, the saga stays in its compensate phase and the keepalive reminder keeps re-driving it until it completes; operators can inspect the failure message the saga records in its persisted state. This is rare in practice and limited to total-storage-outage scenarios.