diff options
Diffstat (limited to 'lib/mnesia/test/mnesia_consistency_test.erl')
-rw-r--r-- | lib/mnesia/test/mnesia_consistency_test.erl | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/lib/mnesia/test/mnesia_consistency_test.erl b/lib/mnesia/test/mnesia_consistency_test.erl index 9cc84de87b..2fe1bd34e6 100644 --- a/lib/mnesia/test/mnesia_consistency_test.erl +++ b/lib/mnesia/test/mnesia_consistency_test.erl @@ -665,10 +665,10 @@ consistency_after_restore(ReplicaType, Op, Config) -> [lists:foreach(fun(E) -> ok = mnesia:dirty_write({Tab, E, 2}) end, NList) || Tab <- Tabs], - Pids1 = [{'EXIT', spawn_link(?MODULE, change_tab, [self(), carA, Op]), ok} || _ <- lists:seq(1, 5)], - Pids2 = [{'EXIT', spawn_link(?MODULE, change_tab, [self(), carB, Op]), ok} || _ <- lists:seq(1, 5)], - Pids3 = [{'EXIT', spawn_link(?MODULE, change_tab, [self(), carC, Op]), ok} || _ <- lists:seq(1, 5)], - Pids4 = [{'EXIT', spawn_link(?MODULE, change_tab, [self(), carD, Op]), ok} || _ <- lists:seq(1, 5)], + Pids1 = [{'EXIT', spawn_link(?MODULE, change_tab, [self(), carA, Op]), carA} || _ <- lists:seq(1, 5)], + Pids2 = [{'EXIT', spawn_link(?MODULE, change_tab, [self(), carB, Op]), carB} || _ <- lists:seq(1, 5)], + Pids3 = [{'EXIT', spawn_link(?MODULE, change_tab, [self(), carC, Op]), carC} || _ <- lists:seq(1, 5)], + Pids4 = [{'EXIT', spawn_link(?MODULE, change_tab, [self(), carD, Op]), carD} || _ <- lists:seq(1, 5)], AllPids = Pids1 ++ Pids2 ++ Pids3 ++ Pids4, @@ -678,19 +678,38 @@ consistency_after_restore(ReplicaType, Op, Config) -> Else -> Else end end, - + timer:sleep(timer:seconds(Delay)), %% Let changers grab locks ?verbose("Doing restore~n", []), ?match(Tabs, Restore(File, [{default_op, Op}])), - timer:sleep(timer:seconds(Delay)), %% Let em die + Collect = fun(Msg, Acc) -> + receive Msg -> Acc + after 10000 -> [Msg|Acc] + end + end, - ?match_multi_receive(AllPids), + Failed1 = lists:foldl(Collect, [], AllPids), + Failed = lists:foldl(Collect, [], Failed1), + + case Failed of + [] -> ok; + _ -> + ?match([], Failed), + io:format("TIME: ~p sec~n", [erlang:system_time(seconds) band 16#FF]), + Dbg = fun({_, Pid, Tab}) -> + io:format("Tab ~p: ~p~n",[Tab, process_info(Pid, current_stacktrace)]), + [io:format(" ~p~n", [Rec]) || Rec <- mnesia:dirty_match_object({Tab, '_', '_'})] + end, + [Dbg(Msg) || Msg <- Failed], + io:format(" Held: ~p~n", [mnesia_locker:get_held_locks()]), + io:format("Queue: ~p~n", [mnesia_locker:get_lock_queue()]) + end, - case ?match(ok, restore_verify_tabs(Tabs)) of - {success, ok} -> + case ?match(ok, restore_verify_tabs(Tabs)) of + {success, ok} -> file:delete(File); - _ -> + _ -> {T, M, S} = time(), File2 = ?flat_format("consistency_error~w~w~w.BUP", [T, M, S]), file:rename(File, File2) @@ -700,17 +719,20 @@ consistency_after_restore(ReplicaType, Op, Config) -> change_tab(Father, Tab, Test) -> Key = rand:uniform(20), Update = fun() -> + Time = erlang:system_time(seconds) band 16#FF, + case put(time, Time) of + Time -> ok; + _ -> io:format("~p ~p ~p sec~n", [self(), Tab, Time]) + end, case mnesia:read({Tab, Key}) of - [{Tab, Key, 1}] -> - quit; - [{Tab, Key, _N}] -> - mnesia:write({Tab, Key, 3}) + [{Tab, Key, 1}] -> quit; + [{Tab, Key, _N}] -> mnesia:write({Tab, Key, 3}) end end, case mnesia:transaction(Update) of {atomic, quit} -> - exit(ok); - {aborted, {no_exists, Tab}} when Test == recreate_tables ->%% I'll allow this + exit(Tab); + {aborted, {no_exists, Tab}} when Test == recreate_tables -> %% I'll allow this change_tab(Father, Tab, Test); {atomic, ok} -> change_tab(Father, Tab, Test) |