revert storage transaction

This block is part of the storage group and was last modified in core v15.0.1.

revert storage transaction v15.0.1

Undoes every document write journaled by a storage transaction, newest first, refusing documents that changed since.

In pins 4 + flow
  • flow
    flow
  • transaction id
    value

    Leave empty to revert the transaction open in this flow. A bare id names a transaction this blueprint started; the qualified `bp::` reference from the start block names one started elsewhere.

  • dry run
    condition

    Report what would be reverted without writing anything.

  • force
    condition

    Skip the update_hash checks: restore the journal's state even over documents changed since. Also reverts a transaction another live run holds open.

  • trigger storage events
    condition

    Let the undo writes fire storage_event flows (off by default).

Out pins 7 + flow
  • flow
    flow
  • success
    condition

    True only when every op was undone.

  • transaction id
    value
  • report
    object
  • status
    value
  • reverted ops
    number
  • conflicts
    number

    Ops that could not be undone (conflicts and failures).

  • error
    value

Reverts a storage transaction by id (or the one open in this flow when none is wired): walks its journal newest-first and undoes each write : a created document is hard-deleted, an updated one gets its pre-write fields back, a removed one is restored, a restored one is removed again, a hard-deleted one is recreated under its guid. Each undo checks the document's _meta.update_hash is still what the journal recorded; a document written since by anything else is reported as a conflict and left alone, so a revert never overwrites work it did not do. success is true only when every op was undone (report.complete); otherwise error is TRANSACTION_REVERT_CONFLICT and `report.ops[]` names each op's outcome (reverted, conflict, failed, skipped) and reason (document_changed, document_missing, not_removed, no_recovery_data, already_gone, …). Works on open, committed and previously failed transactions. Ownership is the attempt token the start block put in this flow; a transaction addressed by a wired id (this blueprint's, or the qualified `bp:<blueprint>:<id>` reference) can be reverted only once its opener's lease has lapsed : otherwise TRANSACTION_IN_PROGRESS, unless force is on. `force` skips the hash checks and restores the journal's state over whatever the documents hold now. `dry_run` reports the plan and touches nothing. The undo writes do not fire storage_event flows unless trigger_storage_events is on; they always record revisions. In simulation it is always a dry run.

A typical wiring for revert storage transaction: a function trigger starts the flow; the flow out pin feeds debug.

Studio canvas example for the revert storage transaction block: typical wiring for revert storage transaction.

Version history

Introduced in v15.0.1.


Back to storage Return to the main group to view all sub-groups Back to storage Return to the group to view all blocks within this group