Table of Contents

Snapshots

This page is part of the documentation for Orleans.Lattice 9.9.0 (release line 9.9), built 2026-10-04. It is also published as markdown, with every table and list, at README.md, and llms.txt lists every page.

What it shows

SnapshotAsync copies a tree into a new destination tree - an offline snapshot as a point-in-time copy - which is useful for backups, read-only analytics forks, or cloning a dataset for experimentation. The copy carries only live entries (never tombstoned or expired ones) and follows the tree's shard map, so it covers every physical shard the map routes to, including one an adaptive split added; an online snapshot does not mirror typed CRDT deltas or bulk appends (see Snapshots). This sample uses SnapshotMode.Offline: every source shard is locked when the copy starts and each is unlocked again once its own entries have been copied, producing a strictly consistent image. It then verifies the copy matches the source and shows the two trees are fully independent (editing one never affects the other).

Switching to SnapshotMode.Online is a one-line change (SnapshotMode.Online): the source then stays readable and writable throughout the copy, with live mutations mirrored to the destination. Offline trades source availability (a shard stays locked until its own copy completes) for the simplest consistency story; online keeps the source hot.

Runtime note: SnapshotAsync runs a crash-safe coordinator that advances one shard step per two-second timer tick, and an offline copy spends two ticks on each shard (copy it, then unlock it). A tree defaults to 64 physical shards, so this sample takes a few minutes to complete even though it only holds 12 keys - snapshot cost scales with shard count, not key count.

Run it

dotnet run --project samples/Snapshots

Expected output

The progress dots appear once per second while the copy runs; the total time depends on your machine (about 4-5 minutes for the default 64-shard tree).

Silo starting... ready.

Seeding source tree 'orders' with 12 keys...
  source count = 12

Offline snapshot: orders -> orders-backup ....[ ~4 minutes of progress dots ].... done in 259s.

Verifying the snapshot:
  backup live-key count = 12 (expected 12)
  backup[order:005]     = "amount=50"
  source readable again = True

Independence after editing each tree separately:
  backup[order:005] = "edited-in-backup" (edited)
  source[order:005] = "amount=50" (unchanged)
  source[order:999] = "new-in-source" (new)
  backup[order:999] = <absent> (not in the snapshot)

Done: the offline snapshot produced an independent point-in-time copy.

When to use

  • Backups or scheduled point-in-time copies of a tree.
  • Forking a dataset into an independent tree for analytics or experimentation without touching production data.
  • Online mode when the source cannot tolerate any read/write interruption during the copy.

When not to use

  • Isolating a single reader from concurrent writes - you do not need a whole second tree; open a snapshot cursor instead (see SnapshotCursors).
  • Latency-sensitive paths that need the copy to finish quickly on a high-shard-count tree - snapshot time scales with shard count.

Feature doc