module Nn_commit:Two-phase commit protocolsig
..end
val commit_e : (unit -> Nn_db.modification Queue.t) ->
(bool -> unit) -> Nn_state.shared_state_t -> string -> bool Uq_engines.engine
commit_e get_journal post_commit shared_state debug_name
:
First gets the modifications by running get_commit
.
Writes the modifications to the local database and all slaves,
and commits the update. The bool arg says whether the commit
was successful. If false
, the transaction is guaranteed to be
rolled back. The commit engine may also enter an error state.
This is considered as a critical violation of the protocol.
If the queue of modification is empty, the local transaction is committed, and no remote operations are involved. (This means that the user only submitted read requests and no writes.)
If there are modifications, a new revision string is created and appended to the journal before anything is written.
The function invokes post_commit
when the commit or
rollback is done. The bool arg is the same as in the result.
Commits are serialized (using finish_transaction_serialized
).
The serialized code section includes the calls of get_journal
and post_commit
.
As side effects, the function may disable slaves, and even
(self-)disable the coordinator.
val trans_e : Nn_state.shared_state_t ->
Nn_state.view_t list ->
'a Uq_engines.engine -> string -> 'a Uq_engines.final_state Uq_engines.engine
let e' = trans_e sh vl e debug_name
: Runs the engine e
until
it is finished,
and if e
was successful, the modifications of the views vl
are taken as the modifications to be done in the transaction,
and the transaction is committed.
If e
is not successful,
the views and the db transaction are rolled back.
The returned engine e'
is `Done(st)
when
the transaction is over (after commit or rollback). st
reflects the
final state of e
.
e'
reaches an error state only if the commit fails (critical error).