Lines Matching refs:Tid

210 	{_From, {async_dirty, Tid, Commit, Tab}} ->
213 do_async_dirty(Tid, new_cr_format(Commit), Tab),
216 Item = {async_dirty, Tid, new_cr_format(Commit), Tab},
221 {From, {sync_dirty, Tid, Commit, Tab}} ->
224 do_sync_dirty(From, Tid, new_cr_format(Commit), Tab),
227 Item = {sync_dirty, From, Tid, new_cr_format(Commit), Tab},
238 Tid = #tid{pid = tmpid(From), counter = C},
239 A2 = gb_trees:insert(Tid,[Etab],Coordinators),
241 reply(From, {new_tid, Tid, Etab}, S2)
248 {From, {ask_commit, Protocol, Tid, Commit0, DiscNs, RamNs}} ->
250 [{tid, Tid}, {prot, Protocol}]),
251 mnesia_checkpoint:tm_enter_pending(Tid, DiscNs, RamNs),
255 node(Tid#tid.pid) =:= node() ->
258 Args = [Protocol, tmpid(From), Tid, Commit, DiscNs, RamNs],
261 reply(From, {vote_yes, Tid}),
264 P = #participant{tid = Tid,
270 State2 = State#state{participants = gb_trees:insert(Tid,P,Participants)},
273 {Tid, do_commit} ->
274 case gb_trees:lookup(Tid, Participants) of
276 verbose("Tried to commit a non participant transaction ~p~n",[Tid]),
279 ?eval_debug_fun({?MODULE,do_commit,pre},[{tid,Tid},{participant,P}]),
291 mnesia_recover:note_decision(Tid, committed),
292 do_commit(Tid, Commit),
295 Tid#tid.pid ! {?MODULE, node(), {committed, Tid}};
299 mnesia_locker:release_tid(Tid),
300 transaction_terminated(Tid),
301 ?eval_debug_fun({?MODULE,do_commit,post},[{tid,Tid},{pid,nopid}]),
303 gb_trees:delete(Tid,Participants)});
305 Pid ! {Tid, committed},
306 ?eval_debug_fun({?MODULE, do_commit, post}, [{tid, Tid}, {pid, Pid}]),
311 {Tid, simple_commit} ->
312 mnesia_recover:note_decision(Tid, committed),
313 mnesia_locker:release_tid(Tid),
314 transaction_terminated(Tid),
317 {Tid, {do_abort, Reason}} ->
318 ?eval_debug_fun({?MODULE, do_abort, pre}, [{tid, Tid}]),
319 case gb_trees:lookup(Tid, Participants) of
322 [Tid, Reason]),
323 mnesia_locker:release_tid(Tid),
329 mnesia_recover:note_decision(Tid, aborted),
330 do_abort(Tid, Commit),
333 Tid#tid.pid ! {?MODULE, node(), {aborted, Tid}};
337 transaction_terminated(Tid),
338 mnesia_locker:release_tid(Tid),
339 ?eval_debug_fun({?MODULE, do_abort, post}, [{tid, Tid}, {pid, nopid}]),
341 gb_trees:delete(Tid,Participants)});
343 Pid ! {Tid, {do_abort, Reason}},
345 [{tid, Tid}, {pid, Pid}]),
350 {From, {add_store, Tid}} -> %% new store for nested transaction
353 A2 = add_coord_store(Coordinators, Tid, Etab),
362 {From, {del_store, Tid, Current, Obsolete, PropagateStore}} ->
364 A2 = del_coord_store(Coordinators, Tid, Current, Obsolete),
370 {From, {restart, Tid, Store}} ->
371 A2 = restore_stores(Coordinators, Tid, Store),
375 reply(From, {restarted, Tid}, State#state{coordinators = A2});
377 {delete_transaction, Tid} ->
380 case gb_trees:is_defined(Tid, Participants) of
382 case gb_trees:lookup(Tid, Coordinators) of
385 [Tid]),
390 transaction_terminated(Tid),
392 gb_trees:delete(Tid,Coordinators)})
395 transaction_terminated(Tid),
396 State2 = State#state{participants=gb_trees:delete(Tid,Participants)},
400 {sync_trans_serial, Tid} ->
402 mnesia_recover:sync_trans_tid_serial(Tid),
481 do_sync_dirty(From, Tid, Commit, _Tab) ->
482 ?eval_debug_fun({?MODULE, sync_dirty, pre}, [{tid, Tid}]),
483 Res = do_dirty(Tid, Commit),
484 ?eval_debug_fun({?MODULE, sync_dirty, post}, [{tid, Tid}]),
487 do_async_dirty(Tid, Commit, _Tab) ->
488 ?eval_debug_fun({?MODULE, async_dirty, pre}, [{tid, Tid}]),
489 do_dirty(Tid, Commit),
490 ?eval_debug_fun({?MODULE, async_dirty, post}, [{tid, Tid}]).
497 {async_dirty, Tid, Commit, Tab} ->
498 do_async_dirty(Tid, Commit, Tab),
500 {sync_dirty, From, Tid, Commit, Tab} ->
501 do_sync_dirty(From, Tid, Commit, Tab),
512 prepare_pending_coordinators([{Tid, [Store | _Etabs]} | Coords], IgnoreNew) ->
517 case lists:member(Tid, IgnoreNew) of
531 Tid = Part#participant.tid,
534 case lists:member(Tid, IgnoreNew) of
536 mnesia_checkpoint:tm_enter_pending(Tid, D, R);
569 {{Tid, Etabs}, RestC} ->
575 recover_coordinator(Tid, Etabs),
579 recover_coordinator(Tid, Etabs) ->
580 verbose("Coordinator ~p in transaction ~p died.~n", [Tid#tid.pid, Tid]),
585 try arrange(Tid, Store, async) of
589 Outcome = tell_outcome(Tid, Protocol, node(), CheckNodes, TellNodes),
597 [{tid, Tid}, {outcome, Outcome}, {prot, Protocol}]),
598 recover_coordinator(Tid, Protocol, Outcome, Local, DiscNs, RamNs),
600 [{tid, Tid}, {outcome, Outcome}, {prot, Protocol}]);
606 [Tid, {Reason, Stacktrace}]),
608 tell_outcome(Tid, Protocol, node(), CheckNodes, TellNodes)
611 transaction_terminated(Tid),
612 mnesia_locker:release_tid(Tid).
614 recover_coordinator(Tid, sym_trans, committed, Local, _, _) ->
615 mnesia_recover:note_decision(Tid, committed),
616 do_dirty(Tid, Local);
617 recover_coordinator(Tid, sym_trans, aborted, _Local, _, _) ->
618 mnesia_recover:note_decision(Tid, aborted);
619 recover_coordinator(Tid, sync_sym_trans, committed, Local, _, _) ->
620 mnesia_recover:note_decision(Tid, committed),
621 do_dirty(Tid, Local);
622 recover_coordinator(Tid, sync_sym_trans, aborted, _Local, _, _) ->
623 mnesia_recover:note_decision(Tid, aborted);
625 recover_coordinator(Tid, Protocol, committed, Local, DiscNs, RamNs)
627 D = #decision{tid = Tid, outcome = committed,
630 do_commit(Tid, Local);
631 recover_coordinator(Tid, Protocol, aborted, Local, DiscNs, RamNs)
633 D = #decision{tid = Tid, outcome = aborted,
636 do_abort(Tid, Local).
638 restore_stores(Coords, Tid, Store) ->
639 Etstabs = gb_trees:get(Tid,Coords),
642 gb_trees:update(Tid,[Store],Coords).
644 add_coord_store(Coords, Tid, Etab) ->
645 Stores = gb_trees:get(Tid, Coords),
646 gb_trees:update(Tid, [Etab|Stores], Coords).
648 del_coord_store(Coords, Tid, Current, Obsolete) ->
649 Stores = gb_trees:get(Tid, Coords),
656 gb_trees:update(Tid, [Current|Rest], Coords).
713 pid_search_delete(Pid, [Tr = {Tid, _Ts} | Trs], _Val, Ack) when Tid#tid.pid == Pid ->
721 transaction_terminated(Tid) ->
722 mnesia_checkpoint:tm_exit_pending(Tid),
723 Pid = Tid#tid.pid,
728 mnesia_recover:sync_trans_tid_serial(Tid)
770 {OldMod, Tid, Ts} -> % Nested
771 execute_inner(Mod, Tid, OldMod, Ts, Fun, Args, Factor, Retries, Type);
780 {new_tid, Tid, Store} ->
782 NewTidTs = {Mod, Tid, Ts},
787 execute_inner(Mod, Tid, OldMod, Ts, Fun, Args, Factor, Retries, Type) ->
788 case req({add_store, Tid}) of
797 NewTidTs = {Mod, Tid, NewTs},
867 {Mod, Tid, Ts} = get(mnesia_activity_state),
870 restart(Mod, Tid, Ts, Fun, Args, Factor, Retries, Type, Why);
887 restart(Mod, Tid, Ts, Fun, Args, Factor0, Retries0, Type, Why) ->
894 SleepTime = mnesia_lib:random_time(Factor, Tid#tid.counter),
895 dbg_out("Restarting transaction ~w: in ~wms ~w~n", [Tid, SleepTime, Why]),
901 SleepTime = mnesia_lib:random_time(Factor, Tid#tid.counter),
902 dbg_out("Restarting transaction ~w: in ~wms ~w~n", [Tid, SleepTime, Why]),
906 SleepTime = mnesia_lib:random_time(Factor0, Tid#tid.counter),
907 dbg_out("Restarting transaction ~w: in ~wms ~w~n", [Tid, SleepTime, Why]),
915 verbose("Sync serial ~p~n", [Tid]),
916 rpc:abcast(AllNodes, ?MODULE, {sync_trans_serial, Tid})
918 intercept_friends(Tid, Ts),
921 ?MODULE ! {self(), {restart, Tid, Store}},
922 mnesia_locker:send_release_tid(Nodes, Tid),
924 mnesia_locker:receive_release_tid_acc(Nodes, Tid),
925 case get_restarted(Tid) of
926 {restarted, Tid} ->
934 get_restarted(Tid) ->
936 {restarted, Tid} ->
941 get_restarted(Tid)
949 {_Mod, Tid, Ts} = get(mnesia_activity_state),
951 [Tid, Fun, Args, Reason]),
954 intercept_friends(Tid, Ts),
959 mnesia_locker:async_release_tid(Nodes, Tid),
960 ?SAFE(?MODULE ! {delete_transaction, Tid}),
968 req({del_store, Tid, NewStore, OldStore, true}),
972 NewTidTs = {OldMod, Tid, Ts2},
998 put_activity_id({Mod, Tid = #tid{}, Ts = #tidstore{}},Fun) ->
1007 NewTidTs = {Mod, Tid, Ts},
1066 Tid = {dirty, self()},
1067 Prep = prepare_items(Tid, Tab, Key, [Item], #prep{protocol= Protocol}),
1076 {WaitFor, FirstRes} = async_send_dirty(Tid, CR, Tab, ReadNode),
1082 {WaitFor, FirstRes} = sync_send_dirty(Tid, CR, Tab, []),
1095 {_Mod, Tid, Ts} = get(mnesia_activity_state),
1099 intercept_friends(Tid, Ts),
1101 case arrange(Tid, Store, Type) of
1105 Tid, Prep#prep.records, Store);
1109 Tid, Prep#prep.records, Store)
1115 req({del_store, Tid, Store, Obsolete, false}),
1119 NewTidTs = {OldMod, Tid, NewTs},
1132 arrange(Tid, Store, Type) ->
1143 {New, Prepared} = do_arrange(Tid, Store, Key, Prep, N),
1167 do_arrange(Tid, Store, {Tab, Key}, Prep, N) ->
1170 P2 = prepare_items(Tid, Tab, Key, Items, Prep),
1171 do_arrange(Tid, Store, ?ets_next(Store, Oid), P2, N + 1);
1172 do_arrange(Tid, Store, SchemaKey, Prep, N) when SchemaKey == op ->
1174 P2 = prepare_schema_items(Tid, Items, Prep),
1175 do_arrange(Tid, Store, ?ets_next(Store, SchemaKey), P2, N + 1);
1176 do_arrange(Tid, Store, RestoreKey, Prep, N) when RestoreKey == restore_op ->
1180 do_prepare_items(Tid, Tab, Key, Where, Snmp, Item, CommitRecs);
1192 do_prepare_items(Tid, Tab, Key, Where, Snmp, Item, CommitRecs)
1196 do_arrange(Tid, Store, ?ets_next(Store, RestoreKey), P2, N + 1);
1204 do_arrange(Tid, Store, sticky, Prep, N) ->
1206 do_arrange(Tid, Store, ?ets_next(Store, sticky), P2, N);
1207 do_arrange(Tid, Store, IgnoredKey, Prep, N) -> %% locks, nodes ... local atoms...
1208 do_arrange(Tid, Store, ?ets_next(Store, IgnoredKey), Prep, N).
1211 prepare_schema_items(Tid, Items, Prep) ->
1213 Recs = prepare_nodes(Tid, Types, Items, Prep#prep.records, schema),
1217 prepare_items(Tid, Tab, Key, Items, Prep) when Prep#prep.prev_tab == Tab ->
1221 Recs2 = do_prepare_items(Tid, Tab, Key, Types, Snmp, Items, Recs),
1224 prepare_items(Tid, Tab, Key, Items, Prep) ->
1230 prepare_items(Tid, Tab, Key, Items, Prep);
1234 Recs2 = do_prepare_items(Tid, Tab, Key, Types,
1242 do_prepare_items(Tid, Tab, Key, Types, Snmp, Items, Recs) ->
1243 Recs2 = prepare_snmp(Tid, Tab, Key, Types, Snmp, Items, Recs), % May exit
1244 prepare_nodes(Tid, Types, Items, Recs2, normal).
1290 prepare_snmp(Tid, Tab, Key, Types, Us, Items, Recs) ->
1294 prepare_nodes(Tid, Types, [{Op, Tab, Key, SnmpOid}], Recs, snmp);
1296 prepare_nodes(Tid, Types, [{clear_table, Tab}], Recs, snmp)
1312 prepare_nodes(Tid, [{Node, Storage} | Rest], Items, C, Kind) ->
1313 {Rec, C2} = pick_node(Tid, Node, C, []),
1315 [Rec2 | prepare_nodes(Tid, Rest, Items, C2, Kind)];
1319 pick_node(Tid, Node, [Rec | Rest], Done) ->
1324 pick_node(Tid, Node, Rest, [Rec | Done])
1367 multi_commit(read_only, _Maj = [], Tid, CR, _Store) ->
1372 Msg = {Tid, simple_commit},
1375 mnesia_recover:note_decision(Tid, committed),
1376 mnesia_locker:release_tid(Tid),
1377 ?MODULE ! {delete_transaction, Tid},
1380 multi_commit(sym_trans, _Maj = [], Tid, CR, Store) ->
1410 Pending = mnesia_checkpoint:tm_enter_pending(Tid, DiscNs, RamNs),
1413 {WaitFor, Local} = ask_commit(sym_trans, Tid, CR, DiscNs, RamNs),
1414 {Outcome, []} = rec_all(WaitFor, Tid, do_commit, []),
1416 [{tid, Tid}, {outcome, Outcome}]),
1417 rpc:abcast(DiscNs -- [node()], ?MODULE, {Tid, Outcome}),
1418 rpc:abcast(RamNs -- [node()], ?MODULE, {Tid, Outcome}),
1421 mnesia_recover:note_decision(Tid, committed),
1422 do_dirty(Tid, Local),
1423 mnesia_locker:release_tid(Tid),
1424 ?MODULE ! {delete_transaction, Tid};
1426 mnesia_recover:note_decision(Tid, aborted)
1429 [{tid, Tid}, {outcome, Outcome}]),
1432 multi_commit(sync_sym_trans, _Maj = [], Tid, CR, Store) ->
1438 Pending = mnesia_checkpoint:tm_enter_pending(Tid, DiscNs, RamNs),
1441 {WaitFor, Local} = ask_commit(sync_sym_trans, Tid, CR, DiscNs, RamNs),
1442 {Outcome, []} = rec_all(WaitFor, Tid, do_commit, []),
1444 [{tid, Tid}, {outcome, Outcome}]),
1446 rpc:abcast(DiscNs -- [node()], ?MODULE, {Tid, Outcome}),
1447 rpc:abcast(RamNs -- [node()], ?MODULE, {Tid, Outcome}),
1450 mnesia_recover:note_decision(Tid, committed),
1452 do_commit(Tid, Local),
1454 rec_all(WaitFor, Tid, ignore, []),
1455 mnesia_locker:release_tid(Tid),
1456 ?MODULE ! {delete_transaction, Tid};
1458 mnesia_recover:note_decision(Tid, aborted)
1461 [{tid, Tid}, {outcome, Outcome}]),
1464 multi_commit(Protocol, Majority, Tid, CR, Store)
1522 D = #decision{tid = Tid, outcome = presume_abort},
1530 Pending = mnesia_checkpoint:tm_enter_pending(Tid, DiscNs, RamNs),
1532 {WaitFor, Local} = ask_commit(Protocol, Tid, CR2, DiscNs, RamNs),
1533 SchemaPrep = ?CATCH(mnesia_schema:prepare_commit(Tid, Local, {coord, WaitFor})),
1534 {Votes, Pids} = rec_all(WaitFor, Tid, do_commit, []),
1537 [{tid, Tid}, {votes, Votes}]),
1544 [{tid, Tid}]),
1550 [{tid, Tid}]),
1551 tell_participants(Pids, {Tid, pre_commit}),
1555 rec_acc_pre_commit(Pids, Tid, Store, {C,Local},
1560 mnesia_recover:note_decision(Tid, aborted),
1562 [{tid, Tid}]),
1563 tell_participants(Pids, {Tid, {do_abort, Reason}}),
1564 do_abort(Tid, Local),
1571 mnesia_recover:note_decision(Tid, aborted),
1572 ?eval_debug_fun({?MODULE, multi_commit_asym_do_abort}, [{tid, Tid}]),
1573 tell_participants(Pids, {Tid, {do_abort, Reason}}),
1574 do_abort(Tid, Local),
1579 rec_acc_pre_commit([Pid | Tail], Tid, Store, Commit, Res, DumperMode,
1582 {?MODULE, _, {acc_pre_commit, Tid, Pid, true}} ->
1583 rec_acc_pre_commit(Tail, Tid, Store, Commit, Res, DumperMode,
1586 {?MODULE, _, {acc_pre_commit, Tid, Pid, false}} ->
1587 rec_acc_pre_commit(Tail, Tid, Store, Commit, Res, DumperMode,
1590 {?MODULE, _, {acc_pre_commit, Tid, Pid}} ->
1592 rec_acc_pre_commit(Tail, Tid, Store, Commit, Res, DumperMode,
1594 {?MODULE, _, {do_abort, Tid, Pid, _Reason}} ->
1596 rec_acc_pre_commit(Tail, Tid, Store, Commit, AbortRes, DumperMode,
1600 ?SAFE(Pid ! {Tid, AbortRes}), %% Tell him that he has died
1601 rec_acc_pre_commit(Tail, Tid, Store, Commit, AbortRes, DumperMode,
1604 rec_acc_pre_commit([], Tid, Store, {Commit,OrigC}, Res, DumperMode, GoodPids, AckPids) ->
1612 tell_participants(GoodPids, {Tid, committed}),
1616 [{tid, Tid}]),
1620 do_commit(Tid, Commit, DumperMode),
1622 [{tid, Tid}]),
1623 sync_schema_commit(Tid, Store, AckPids),
1624 mnesia_locker:release_tid(Tid),
1625 ?MODULE ! {delete_transaction, Tid};
1628 tell_participants(GoodPids, {Tid, {do_abort, Reason}}),
1632 [{tid, Tid}]),
1633 do_abort(Tid, OrigC),
1635 [{tid, Tid}])
1649 sync_schema_commit(Tid, Store, [Pid | Tail]) ->
1651 {?MODULE, _, {schema_commit, Tid, Pid}} ->
1653 sync_schema_commit(Tid, Store, Tail);
1657 sync_schema_commit(Tid, Store, Tail)
1668 commit_participant(Protocol, Coord, Tid, Bin, DiscNs, RamNs) when is_binary(Bin) ->
1671 commit_participant(Protocol, Coord, Tid, Bin, Commit, DiscNs, RamNs);
1672 commit_participant(Protocol, Coord, Tid, C = #commit{}, DiscNs, RamNs) ->
1674 commit_participant(Protocol, Coord, Tid, C, C, DiscNs, RamNs).
1676 commit_participant(Protocol, Coord, Tid, Bin, C0, DiscNs, _RamNs) ->
1677 ?eval_debug_fun({?MODULE, commit_participant, pre}, [{tid, Tid}]),
1678 try mnesia_schema:prepare_commit(Tid, C0, {part, Coord}) of
1692 [{tid, Tid}]),
1693 reply(Coord, {vote_yes, Tid, self()}),
1696 {Tid, pre_commit} ->
1700 [{tid, Tid}]),
1703 reply(Coord, {acc_pre_commit, Tid, self(), ExpectAck}),
1708 {Tid, committed} ->
1711 [{tid, Tid}]),
1712 do_commit(Tid, C, DumperMode),
1715 true -> reply(Coord, {schema_commit, Tid, self()})
1718 [{tid, Tid}]);
1720 {Tid, {do_abort, _Reason}} ->
1723 [{tid, Tid}]),
1724 mnesia_schema:undo_prepare_commit(Tid, C0),
1726 [{tid, Tid}]);
1729 reply(Coord, {do_abort, Tid, self(), {bad_commit,Reason}}),
1731 mnesia_schema:undo_prepare_commit(Tid, C0);
1735 [Tid, Msg])
1737 {Tid, {do_abort, Reason}} ->
1738 reply(Coord, {do_abort, Tid, self(), Reason}),
1739 mnesia_schema:undo_prepare_commit(Tid, C0),
1741 [{tid, Tid}]);
1744 reply(Coord, {do_abort, Tid, self(), {bad_commit,Reason}}),
1745 mnesia_schema:undo_prepare_commit(Tid, C0),
1746 ?eval_debug_fun({?MODULE, commit_participant, pre_commit_undo_prepare}, [{tid, Tid}]);
1749 reply(Coord, {do_abort, Tid, self(), {bad_commit,internal}}),
1751 [Tid, Msg])
1755 [{tid, Tid}]),
1756 reply(Coord, {vote_no, Tid, Reason}),
1757 mnesia_schema:undo_prepare_commit(Tid, C0)
1759 mnesia_locker:release_tid(Tid),
1760 ?MODULE ! {delete_transaction, Tid},
1764 do_abort(Tid, Bin) when is_binary(Bin) ->
1772 do_abort(Tid, binary_to_term(Bin));
1773 do_abort(Tid, Commit) ->
1774 mnesia_schema:undo_prepare_commit(Tid, Commit),
1777 do_dirty(Tid, Commit) when Commit#commit.schema_ops == [] ->
1779 do_commit(Tid, Commit).
1782 do_commit(Tid, Bin) when is_binary(Bin) ->
1783 do_commit(Tid, binary_to_term(Bin));
1784 do_commit(Tid, C) ->
1785 do_commit(Tid, C, optional).
1787 do_commit(Tid, Bin, DumperMode) when is_binary(Bin) ->
1788 do_commit(Tid, binary_to_term(Bin), DumperMode);
1789 do_commit(Tid, C, DumperMode) ->
1790 mnesia_dumper:update(Tid, C#commit.schema_ops, DumperMode),
1791 R = do_snmp(Tid, proplists:get_value(snmp, C#commit.ext, [])),
1792 R2 = do_update(Tid, ram_copies, C#commit.ram_copies, R),
1793 R3 = do_update(Tid, disc_copies, C#commit.disc_copies, R2),
1794 R4 = do_update(Tid, disc_only_copies, C#commit.disc_only_copies, R3),
1795 R5 = do_update_ext(Tid, C#commit.ext, R4),
1796 mnesia_subscr:report_activity(Tid),
1801 do_update_ext(Tid, Ext, OldRes) ->
1806 do_update(Tid, Storage, [Op], R)
1812 do_update(Tid, Storage, [Op | Ops], OldRes) ->
1813 try do_update_op(Tid, Storage, Op) of
1814 ok -> do_update(Tid, Storage, Ops, OldRes);
1815 NewRes -> do_update(Tid, Storage, Ops, NewRes)
1824 [Tid, Op, {Reason, ST}]),
1825 do_update(Tid, Storage, Ops, OldRes)
1830 do_update_op(Tid, Storage, {{Tab, K}, Obj, write}) ->
1831 commit_write(?catch_val({Tab, commit_work}), Tid, Storage,
1835 do_update_op(Tid, Storage, {{Tab, K}, Val, delete}) ->
1836 commit_delete(?catch_val({Tab, commit_work}), Tid, Storage, Tab, K, Val, undefined),
1839 do_update_op(Tid, Storage, {{Tab, K}, {RecName, Incr}, update_counter}) ->
1854 commit_update(?catch_val({Tab, commit_work}), Tid, Storage, Tab,
1858 do_update_op(Tid, Storage, {{Tab, Key}, Obj, delete_object}) ->
1860 Tid, Storage, Tab, Key, Obj),
1863 do_update_op(Tid, Storage, {{Tab, Key}, Obj, clear_table}) ->
1864 commit_clear(?catch_val({Tab, commit_work}), Tid, Storage, Tab, Key, Obj),
1868 commit_write([{checkpoints, CpList}|R], Tid, Storage, Tab, K, Obj, Old) ->
1869 mnesia_checkpoint:tm_retain(Tid, Tab, K, write, CpList),
1870 commit_write(R, Tid, Storage, Tab, K, Obj, Old);
1871 commit_write([H|R], Tid, Storage, Tab, K, Obj, Old)
1873 mnesia_subscr:report_table_event(H, Tab, Tid, Obj, write, Old),
1874 commit_write(R, Tid, Storage, Tab, K, Obj, Old);
1875 commit_write([H|R], Tid, Storage, Tab, K, Obj, Old)
1878 commit_write(R, Tid, Storage, Tab, K, Obj, Old).
1881 commit_update([{checkpoints, CpList}|R], Tid, Storage, Tab, K, Obj, _) ->
1882 Old = mnesia_checkpoint:tm_retain(Tid, Tab, K, write, CpList),
1883 commit_update(R, Tid, Storage, Tab, K, Obj, Old);
1884 commit_update([H|R], Tid, Storage, Tab, K, Obj, Old)
1886 mnesia_subscr:report_table_event(H, Tab, Tid, Obj, write, Old),
1887 commit_update(R, Tid, Storage, Tab, K, Obj, Old);
1888 commit_update([H|R], Tid,Storage, Tab, K, Obj, Old)
1891 commit_update(R, Tid, Storage, Tab, K, Obj, Old).
1894 commit_delete([{checkpoints, CpList}|R], Tid, Storage, Tab, K, Obj, _) ->
1895 Old = mnesia_checkpoint:tm_retain(Tid, Tab, K, delete, CpList),
1896 commit_delete(R, Tid, Storage, Tab, K, Obj, Old);
1897 commit_delete([H|R], Tid, Storage, Tab, K, Obj, Old)
1899 mnesia_subscr:report_table_event(H, Tab, Tid, Obj, delete, Old),
1900 commit_delete(R, Tid, Storage, Tab, K, Obj, Old);
1901 commit_delete([H|R], Tid, Storage, Tab, K, Obj, Old)
1904 commit_delete(R, Tid, Storage, Tab, K, Obj, Old).
1907 commit_del_object([{checkpoints, CpList}|R], Tid, Storage, Tab, K, Obj) ->
1908 mnesia_checkpoint:tm_retain(Tid, Tab, K, delete_object, CpList),
1909 commit_del_object(R, Tid, Storage, Tab, K, Obj);
1910 commit_del_object([H|R], Tid, Storage, Tab, K, Obj) when element(1, H) == subscribers ->
1911 mnesia_subscr:report_table_event(H, Tab, Tid, Obj, delete_object),
1912 commit_del_object(R, Tid, Storage, Tab, K, Obj);
1913 commit_del_object([H|R], Tid, Storage, Tab, K, Obj) when element(1, H) == index ->
1915 commit_del_object(R, Tid, Storage, Tab, K, Obj).
1918 commit_clear([{checkpoints, CpList}|R], Tid, Storage, Tab, K, Obj) ->
1919 mnesia_checkpoint:tm_retain(Tid, Tab, K, clear_table, CpList),
1920 commit_clear(R, Tid, Storage, Tab, K, Obj);
1921 commit_clear([H|R], Tid, Storage, Tab, K, Obj)
1923 mnesia_subscr:report_table_event(H, Tab, Tid, Obj, clear_table, undefined),
1924 commit_clear(R, Tid, Storage, Tab, K, Obj);
1925 commit_clear([H|R], Tid, Storage, Tab, K, Obj)
1928 commit_clear(R, Tid, Storage, Tab, K, Obj).
1931 do_snmp(Tid, [Head|Tail]) ->
1938 [Tid, Head, {Reason, ST}])
1940 do_snmp(Tid, Tail).
1989 sync_send_dirty(Tid, [Head | Tail], Tab, WaitFor) ->
1993 {WF, _} = sync_send_dirty(Tid, Tail, Tab, WaitFor),
1994 Res = do_dirty(Tid, Head),
1997 {?MODULE, Node} ! {self(), {sync_dirty, Tid, Head, Tab}},
1998 sync_send_dirty(Tid, Tail, Tab, [Node | WaitFor])
2006 async_send_dirty(Tid, Nodes, Tab, ReadNode) ->
2007 async_send_dirty(Tid, Nodes, Tab, ReadNode, [], ok).
2009 async_send_dirty(Tid, [Head | Tail], Tab, ReadNode, WaitFor, Res) ->
2013 NewRes = do_dirty(Tid, Head),
2014 async_send_dirty(Tid, Tail, Tab, ReadNode, WaitFor, NewRes);
2016 {?MODULE, Node} ! {self(), {sync_dirty, Tid, Head, Tab}},
2018 async_send_dirty(Tid, Tail, Tab, ReadNode, [Node | WaitFor], NewRes);
2020 {?MODULE, Node} ! {self(), {async_dirty, Tid, Head, Tab}},
2021 async_send_dirty(Tid, Tail, Tab, ReadNode, WaitFor, Res)
2048 {_, Tid, _Ts} when element(1,Tid) == tid ->
2068 ask_commit(Protocol, Tid, CR, DiscNs, RamNs) ->
2069 ask_commit(Protocol, Tid, CR, DiscNs, RamNs, [], no_local).
2071 ask_commit(Protocol, Tid, [Head | Tail], DiscNs, RamNs, WaitFor, Local) ->
2075 ask_commit(Protocol, Tid, Tail, DiscNs, RamNs, WaitFor, Head);
2077 Msg = {ask_commit, convert_old(Protocol, Node), Tid, Head, DiscNs, RamNs},
2079 ask_commit(Protocol, Tid, Tail, DiscNs, RamNs, [Node | WaitFor], Local)
2097 rec_all([Node | Tail], Tid, Res, Pids) ->
2099 {?MODULE, Node, {vote_yes, Tid}} ->
2100 rec_all(Tail, Tid, Res, Pids);
2101 {?MODULE, Node, {vote_yes, Tid, Pid}} ->
2102 rec_all(Tail, Tid, Res, [Pid | Pids]);
2103 {?MODULE, Node, {vote_no, Tid, Reason}} ->
2104 rec_all(Tail, Tid, {do_abort, Reason}, Pids);
2105 {?MODULE, Node, {committed, Tid}} ->
2106 rec_all(Tail, Tid, Res, Pids);
2107 {?MODULE, Node, {aborted, Tid}} ->
2108 rec_all(Tail, Tid, Res, Pids);
2114 ?SAFE({?MODULE, Node} ! {Tid, Abort}),
2115 rec_all(Tail, Tid, Abort, Pids)
2122 lists:map(fun({Tid, _Tabs}) ->
2123 Status = tr_status(Tid,Participant),
2124 {Tid#tid.counter, Tid#tid.pid, Status}
2127 tr_status(Tid,Participant) ->
2128 case lists:keymember(Tid, 1, Participant) of
2155 lists:foreach(fun({Tid, _Tabs}) -> pr_tid(Stream, Tid) end, Coord).
2168 pr_tid(Stream, Tid) ->
2170 [Tid#tid.counter, Tid#tid.pid]).
2180 search_pr_coordinator(S, [{Tid, _Ts}|Tail]) ->
2181 case Tid#tid.counter of
2184 display_pid_info(Tid#tid.pid),
2193 Tid = P#participant.tid,
2196 Tid#tid.counter == S ->
2198 Pid = Tid#tid.pid,
2248 reconfigure_coordinators(N, [{Tid, [Store | _]} | Coordinators]) ->
2249 case mnesia_recover:outcome(Tid, unknown) of
2256 send_mnesia_down(Tid, Store, N)
2260 send_mnesia_down(Tid, Store, N)
2266 send_mnesia_down(Tid, Store, Node) ->
2268 send_to_pids([Tid#tid.pid | get_elements(friends,Store)], Msg).
2290 Tid = P#participant.tid,
2292 node(Tid#tid.pid) /= N ->
2302 [Tid#tid.pid, Tid]),
2308 tell_outcome(Tid, Protocol, N, AliveNodes, AliveNodes),
2318 tell_outcome(Tid, Protocol, Node, CheckNodes, TellNodes) ->
2319 Outcome = mnesia_recover:what_happened(Tid, proto(Protocol), CheckNodes),
2322 rpc:abcast(TellNodes, ?MODULE, {Tid,{do_abort, {mnesia_down, Node}}});
2324 rpc:abcast(TellNodes, ?MODULE, {Tid, do_commit})
2333 lists:foreach(fun({Tid, _}) -> Tid#tid.pid ! Msg end, gb_trees:to_list(Coordinators)),