ReactiveDag.Node.Changes.MarkDirty (reactive_dag v0.17.0-rc)

Copy Markdown View Source

Marks a written record's key dirty on its own cell, so the next drain picks the change up. Wired automatically by dirties_on — hosts do not add it.

Why a change, not a notifier

The obvious tool is an Ash.Notifier, and it is the wrong one: Ash dispatches notifications after the transaction commits. A mark written there is not covered by the write's transaction, so a crash between commit and dispatch loses it — and a lost mark is silent staleness, the failure mode this feature exists to remove.

An after_action hook runs inside the transaction (its counterpart is named before_transaction precisely because that one does not). The dirty write therefore joins the host's transaction through the same repo:

  • a rolled-back write leaves no dirty key, and
  • a committed write always leaves one.

Both halves matter. Neither is true of a notifier.

Cost

The mark is one small INSERT … ON CONFLICT DO NOTHING per write, inside a transaction the host already holds open. A host writing at a rate where that contends should feed the leaf from a ReactiveDag.Source poll instead — see the sources guide.