Ferricstore.CrossShardOp.IntentResolver (ferricstore v0.4.1)

Copy Markdown View Source

Resolves stale intents left by crashed cross-shard operation coordinators.

On startup (or on-demand), scans all shards for intent records with status :executing. For each stale intent:

  • Checks if the intent is old enough to be considered stale (>10s)
  • Reads current lightweight watch tokens for involved keys
  • Compares tokens with the intent snapshot
  • If token matches: data unchanged, safe to clean up the intent
  • If token doesn't match: someone wrote new data, clean up intent (don't re-execute)
  • If key doesn't exist: already completed or expired, clean up intent

Intent records are self-describing: they contain the command type, involved keys, and expected value hashes.

Summary

Functions

Scans all shards for stale intents and cleans them up.

Functions

resolve_stale_intents()

@spec resolve_stale_intents() :: :ok

Scans all shards for stale intents and cleans them up.

This function is safe to call multiple times. It only removes intents whose operations have either completed or are stale.