MishkaInstaller. Helper. MnesiaAssistant. Transaction
(Mishka installer v0.1.11)
Copy Markdown
View Source
Runs Mnesia activities and maps aborted results to the installer's error shape.
Summary
Functions
Runs fun inside a durable transaction: :mnesia.sync_transaction/1 to commit on every node
holding a copy of the table, then :mnesia.sync_log/0 to flush the transaction log to disk before
returning.
Runs fun as a fast, dirty ets activity. Delegates to :mnesia.ets/1.
Runs fun inside a Mnesia transaction. Delegates to :mnesia.transaction/1.
Builds a standard {:error, [map]} from an aborted transaction reason.
Functions
Runs fun inside a durable transaction: :mnesia.sync_transaction/1 to commit on every node
holding a copy of the table, then :mnesia.sync_log/0 to flush the transaction log to disk before
returning.
Use it for writes that must survive an unclean node exit. transaction/1 alone buffers the commit
and only reaches the disk on the periodic dump (dump_log_time_threshold, three minutes by
default), so a node that dies in between comes back with the old record — and a plugin's
:stopped/:started status is an operator's setting, not a cache.
Returns {:atomic, result} or {:aborted, reason}.
Runs fun as a fast, dirty ets activity. Delegates to :mnesia.ets/1.
Only safe for
ram_copiestables or read-only access ondisc_copies.
Runs fun inside a Mnesia transaction. Delegates to :mnesia.transaction/1.
Returns {:atomic, result} or {:aborted, reason}.
Builds a standard {:error, [map]} from an aborted transaction reason.
The returned map carries :message, :field, :action and the raw :source error, so callers
can surface a consistent error across the codebase.
Example
transaction_error(reason, MyTable, "reading", :global, :database)