Table of Contents

Registering Lattice

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 registering-lattice.md, and llms.txt lists every page.

Part of Configuration.

Every silo must call AddLattice to register the grain storage provider that Lattice grains use internally:

siloBuilder.AddLattice((silo, name) => silo.AddMemoryGrainStorage(name));

The name parameter is the storage provider name ("lattice"). Replace AddMemoryGrainStorage with any Orleans storage provider (Azure Blob, Azure Table, ADO.NET, etc.) for durable grain state. The write-ahead log is a separate seam: AddLattice registers an in-memory WAL provider, so a durable deployment also registers a durable WAL provider - see WAL storage providers.

The grain storage provider must enforce ETags

The provider configureStorage registers must enforce ETags (optimistic concurrency) on write: a write that presents an ETag other than the stored row's current one must fail with Orleans' InconsistentStateException. Orleans' memory, Azure Table, Azure Blob, Cosmos DB and ADO.NET providers all do. Lattice depends on it in three ways:

  • Direct writes. The durable write-ahead-log pin store writes its bucketed slots straight through the provider rather than through IPersistentState, and when that grain cannot be reached during shutdown the leaf cursor reporter writes the same slots itself, from outside any grain. Both read a slot and write it back with the ETag they read, so only the provider's ETag check stops one writer from overwriting the other.
  • Duplicate activations. Orleans' default grain directory is eventually consistent, so during a membership change two activations of the same grain can briefly coexist. The provider's ETag check is what rejects the stale activation's write.
  • WAL append fencing. A leaf activation claims its write-ahead-log append epoch with a strict conditional write to a reserved row (_lattice_leaf-append-epoch), and each WAL partition max-merges its per-leaf epoch entries (_lattice_wal-append-epoch), its retired-epoch floor (_lattice_wal-append-epoch-floor), its routing-generation table, one row with a slot per initiator (_lattice_wal-routing-generations) and its append-epoch directory pages (_lattice_wal-append-epoch-dir) through the same provider, the orphaned-row sweep claims each tree's sweep with a conditional write to _lattice_wal-append-fence-sweep, and a purge max-merges each tree id's per-initiator routing floors (_lattice_tree-routing-floor) before it retires the tree's fence rows. Only the ETag check makes the claim exclusive. See WAL append fencing.

With a provider that accepts a stale write, a stale activation can persist an older leaf checkpoint while the durable write-ahead-log pin, which merges by maximum, keeps the newer offset. The write-ahead-log garbage collector can then trim entries a later cold rebuild of that leaf needs. Nothing fails at the time, so the loss is silent.

Each silo checks the requirement once as it becomes active. It writes a reserved probe row (grain type and state name _lattice_grain-storage-fencing-probe, one row shared by the cluster) twice, then writes it again presenting the first, now stale, ETag, and expects InconsistentStateException. What happens next is set by LatticeGrainStorageFencingOptions.Mode:

Mode Provider rejects the stale write Provider accepts the stale write Probe cannot decide
Warn Logs the posture at Information. Logs a Warning; the silo starts. Logs a Warning; the silo starts.
Reject (default) Logs the posture at Information. Logs an Error and fails silo start. Logs a Warning; the silo starts.
Disabled No probe runs; the silo logs once that the check is disabled.

The probe cannot decide when the provider faults, throws something other than InconsistentStateException on the stale write, keeps losing races to other silos' probes, is not registered, or does not finish within ProbeTimeout (30 seconds by default). Those are not evidence the provider is unsafe, so even Reject only warns on them rather than turning a transient storage fault into a failed start.

Providers such as Orleans' Azure Table storage log every write they reject at Error (for Azure Table, Orleans.Storage.AzureTableGrainStorage event 200107) before they throw, so the probe's deliberate stale write would otherwise leave an Error in a healthy silo's log on every start. AddLattice therefore drops the Warning, Error and Critical records written on the probe's own calls into the provider while the probe runs. Nothing is lost by it: each outcome of those calls becomes the verdict above, which Lattice logs itself, a provider fault reaches the log as that Warning with the provider's exception attached, and records from any other work in the silo, or written after the probe finishes, are never dropped. The host's logging levels and filters are otherwise unchanged.

Reject is the default from Orleans.Lattice 10.0.0, so the requirement fails closed: a provider that accepts a stale ETag fails silo start with an error naming the provider. Before Orleans.Lattice 10.0.0 the default was Warn. If your provider does not enforce ETags and you cannot change it yet, opt out explicitly to keep the previous behaviour:

siloBuilder.ConfigureLatticeGrainStorageFencing(o => o.Mode = LatticeGrainStorageFencingMode.Warn);

Prefer fixing the provider (use one that enforces ETags, for example the Azure Table, ADO.NET or Lattice storage providers, or make a custom or test double throw InconsistentStateException when the presented ETag is stale). Use Disabled only for a deliberately non-durable provider, such as a benchmark's no-op storage, where the probe's writes are wasted.

LatticeGrainStorageFencingOptions has these settings:

Option Type Default Validation
Mode LatticeGrainStorageFencingMode Reject Must be a defined LatticeGrainStorageFencingMode value: Warn, Reject or Disabled.
ProbeTimeout TimeSpan 30 seconds Must be positive.