Shutdown back-pressure
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 shutdown-back-pressure.md, and llms.txt lists every page.Part of Atomic Multi-Key Writes.
A saga that is dispatched while the silo is shutting down (the host
has received SIGTERM and the WAL writer is draining) cannot reach the
storage layer - the writer-side drain refuses new appends with the
typed LatticeShuttingDownException. The saga coordinator detects
this regime (and the related Orleans grain-rejection shape that fires
when a leaf grain has been deactivated as part of the same shutdown)
and fast-fails without consuming retry budget: the next retry
would route through the same drained writer and fail identically, so
the saga skips the retry loop and the whole compensate pivot - it
records no abort, broadcasts no terminals, persists nothing, and
leaves its keepalive reminder registered - and surfaces the failure
to the caller as LatticeShuttingDownException.
Because nothing is persisted on this path the saga is not terminal,
so it records no outcome on the orleans.lattice.atomic_write.completed
counter: the operational signal is the LatticeShuttingDownException
at the caller's catch site. (The counter's outcome=shutdown_refused
arm is never produced, because the fast path never reaches the
terminal write that records an outcome.)
Caller contract: treat the LatticeShuttingDownException as back-
pressure. The entries the saga carried were never made visible - at
most they were staged as prepared writes that readers cannot see - and
the silo refused them because the host is going away rather than
because the storage layer rejected them. Long-lived clients should
either fail over to a peer silo (if the cluster is multi-node) or
surface the back-pressure to upstream callers (drop the request, queue
it to a side outbox, or rate-limit). Recovery does not start from
scratch: the saga's persisted state still sits in the execute phase
with its staging progress, so re-issuing the same operationId
re-attaches to that in-flight saga and resumes it rather than starting a
new one. Left alone, the saga is resumed by its keepalive reminder, which
rolls it back rather than committing it (see
Batches whose caller was answered). See API
Reference - Shutdown back-
pressure
for the cross-feature contract.
The saga captures the physical tree, shard-map version, touched shard set
and distinct WAL partitions for its entries together during prepare. Before
each batched dispatch it uses the per-partition WAL saturation signal to quiesce
only those captured WAL partitions; a saturated unrelated partition does
not stall the batch. The wait is capped at the smaller of a 30-second saga
ceiling and the tree's LatticeOptions.WalAppendDispatchTimeout, so the
saga's quiesce always wins over the writer-side admission deadline; it
returns early once the host starts stopping. When the partition-scoped
interface is available and the snapshot contains partitions, it is used
independently; no tree-wide signal is required. If the partition interface
or a usable partition snapshot is unavailable, a registered tree-wide
signal remains the fail-closed fallback. If neither usable signal is
registered, the optional quiesce remains skipped.
The signal is queried under the captured physical tree id, matching the WAL
writer's key. If the shard-map epoch changes before the commit decision,
the saga refreshes and persists its route snapshot, includes both the old
and new shard participants, and re-dispatches the prepared batch against the
new map. A physical-copy change uses the existing rebind path; repeated
routing changes fail before the commit decision rather than committing a
batch against a stale snapshot. If the budget elapses with a captured WAL
partition still Saturated - or the batched dispatch itself is refused as
saturated, by the writer-side admission gate or by the batch write's
SetManyFanOutBudget (finite, 30 s by
default) or, when one is configured,
SetManyEnvelopeBudget - the saga takes a saturation
fast-path that mirrors the shutdown one: it skips the retry and the
compensate pivot (either would re-enter the same throttled storage
account), keeps its persisted progress in the execute phase, and throws
LatticeSaturatedException with source
LatticeSaturationSource.AtomicWriteSaga, counted on
orleans.lattice.saturation.refusals with source=atomic_write_saga. An
inner refusal it wraps was already counted by its own seam (the
writer-side gate under wal_admission, the batch-write budgets under
set_many_fan_out and set_many_envelope), and a refusal because the quiesce
budget elapsed is counted twice under atomic_write_saga. Back off and
retry with the
same operationId once the signal returns to healthy; the saga continues
from its persisted progress, and re-staging a write it already staged is
idempotent. A saga nobody re-issues is rolled back by its keepalive
reminder (see Batches whose caller was answered).