#Persistence & Crash Recovery

Version: 0.33.0 Updated: 2026-03-15 Applies to: ranvier-runtime Category: Deep Dives


Production-grade workflow durability and saga-style compensation.

#Recovery Flow

  1. Append: Runtime saves a checkpoint after every successful step.
  2. Crash: External state remains committed; process state is lost.
  3. Resume: Restarted process loads trace and resumes from the last cursor.

#Durable Adapters

Backend Characteristics
PostgreSQL ACID compliant, multi-process durable storage
Redis High-throughput, sub-millisecond ephemeral checkpoints
InMemory No dependencies, ideal for tests and local development

#Saga Pattern

  • Compensation: Define rollback hooks for irreversible side effects.
  • Idempotency: Ensure compensation runs exactly once per trace.
  • Auto-Trigger: Runtime kicks off hooks automatically on Fault.

#Quickstart

// Cargo.toml: feature persistence-postgres
let store = PostgresPersistenceStore::new(pool);
store.ensure_schema().await?;
bus.insert(PersistenceHandle::from_store(store));

#Workflows

  1. Insert PersistenceHandle into Bus at ingress boundary.
  2. Define CompensationHook for transitions with side effects.
  3. Configure retention (TTL/Purge) based on compliance requirements.
  4. Monitor checkpoint_failures_total metrics in production.

#Key Types

Type Description
PersistenceStore Main trait for storing and resuming workflow events
PersistenceEnvelope Minimal record containing trace_id, step, and outcome
CompensationHook Protocol for defining saga-style rollback logic
IdempotencyStore Contract for preventing duplicate compensation execution