[HELP]How the protocal 'asym_trans' of mnesia guarantee the data consistent

Siyang Zhang zhangsiyang0629725@REDACTED
Thu Mar 19 07:17:35 CET 2020


Hi:

'mnesia_tm' use 3 phases to implement the 'asym_trans' protocol
The first phase is the phase of 'asc_commit', the second is 'pre_commit',
and the third is 'do_commit'.

In the 'do_commit' phase, the code snippet:

%% Now everybody knows that the others
%% has voted yes. We also know that
%% everybody are uncertain.
prepare_sync_schema_commit(Store, SchemaAckPids),
*tell_participants(GoodPids, {Tid, committed}),*
D2 = D#decision{outcome = committed},
mnesia_recover:log_decision(D2),
?eval_debug_fun({?MODULE, rec_acc_pre_commit_log_commit},
[{tid, Tid}]),

%% Now we have safely logged committed
%% and we can recover without asking others
do_commit(Tid, Commit, DumperMode),
?eval_debug_fun({?MODULE, rec_acc_pre_commit_done_commit},
[{tid, Tid}]),
sync_schema_commit(Tid, Store, SchemaAckPids),
mnesia_locker:release_tid(Tid),
?MODULE ! {delete_transaction, Tid};

I'm confused that how this protocol guarantee the data consistent?
The code 'tell_participants(GoodPids, {Tid, committed})' is asynchronous.
If one or more participates down at this moment, the data could be
inconsistent, right ?

If the data become inconsistent, why use asym protocal ???
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20200319/559000e5/attachment.htm>


More information about the erlang-questions mailing list