Skip to content

IJournaledState

interface

Namespace: Orleans.Journaling

Interface for a state which can be persisted to durable storage.
public interface IJournaledState

Remarks

Implementations are owned by a single Orleans.Journaling.JournaledStateManager and are accessed from one logical thread at a time. They participate in the journaling lifecycle as follows:

  • User code mutates in-memory state synchronously (typically by invoking codec helpers that both apply the mutation locally and emit the corresponding command to the journal).
  • At the end of the grain turn, the journaled state manager calls IJournaledState (and occasionally IJournaledState) to materialize the pending changes, then flushes the journal to durable storage.
  • IJournaledState is invoked when the durable write has been acknowledged. Implementations that need to know when state has actually been persisted (for example, to release waiters or trigger downstream notifications) should hook into this callback rather than treating in-memory mutations as durable.
  • On failure, the journaled state manager triggers recovery by calling IJournaledState followed by replaying snapshots and entries from durable storage. Implementations must therefore make any volatile in-memory bookkeeping fully recoverable from the journal.

In other words, in-memory mutations are journaled within the same grain turn and become durable when the journal flushes. Implementations are free to apply mutations eagerly (before the durable write completes); recovery rebuilds in-memory state from the journal, so a turn-failure-and-recovery cycle observably rewinds any unflushed changes.

Methods