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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

Siyang Zhang
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 ???