4949 master_on_non_local_tables /1 ,
5050 remote_force_load_with_local_master_node /1 ,
5151 master_node_with_ram_copy_2 /1 , master_node_with_ram_copy_3 /1 ,
52+ force_load_table_when_loader_aborts_ram /1 ,
53+ force_load_table_when_loader_aborts_disc /1 ,
54+ force_load_table_when_loader_aborts_disc_only /1 ,
55+ force_load_table_when_loader_aborts_ext_ram /1 ,
56+ force_load_table_when_loader_aborts_ext_disc_only /1 ,
57+ force_load_table_when_loader_on_different_pid /1 ,
5258 dump_ram_copies /1 , dump_disc_copies /1 , dump_disc_only /1 ]).
5359
5460-include (" mnesia_test_lib.hrl" ).
@@ -71,7 +77,7 @@ all() ->
7177 durability_of_disc_copies ,
7278 durability_of_disc_only_copies ].
7379
74- groups () ->
80+ groups () ->
7581 [{load_tables , [],
7682 [load_latest_data , load_local_contents_directly ,
7783 load_directly_when_all_are_ram_copiesA ,
@@ -97,8 +103,18 @@ groups() ->
97103 remote_force_load_with_local_master_node ,
98104 master_node_with_ram_copy_2 , master_node_with_ram_copy_3 ]},
99105 {durability_of_dump_tables , [],
100- [dump_ram_copies , dump_disc_copies , dump_disc_only ]}].
101-
106+ [dump_ram_copies , dump_disc_copies , dump_disc_only ]},
107+ {load_tables_with_network_down , [],
108+ [force_load_table_when_loader_aborts_ram ,
109+ force_load_table_when_loader_aborts_disc ,
110+ force_load_table_when_loader_aborts_disc_only ,
111+ force_load_table_when_loader_aborts_ext_ram ,
112+ force_load_table_when_loader_aborts_ext_disc_only ,
113+ force_load_table_when_loader_on_different_pid ]
114+ }].
115+
116+ init_per_group (load_tables_with_network_down , Config ) ->
117+ mnesia_test_lib :skip_if_no_network_blocker (Config );
102118init_per_group (_GroupName , Config ) ->
103119 Config .
104120
@@ -1270,6 +1286,75 @@ master_node_with_ram_copy_3(Config) when is_list(Config) ->
12701286
12711287 ? verify_mnesia (Nodes , []).
12721288
1289+ force_load_table_when_loader_aborts_ram (Config ) ->
1290+ force_load_table_when_loader_aborts (Config , ram_copies ).
1291+
1292+ force_load_table_when_loader_aborts_disc (Config ) ->
1293+ force_load_table_when_loader_aborts (Config , disc_copies ).
1294+
1295+ force_load_table_when_loader_aborts_disc_only (Config ) ->
1296+ force_load_table_when_loader_aborts (Config , disc_only_copies ).
1297+
1298+ force_load_table_when_loader_aborts_ext_ram (Config ) ->
1299+ force_load_table_when_loader_aborts (Config , ext_ram_copies ).
1300+
1301+ force_load_table_when_loader_aborts_ext_disc_only (Config ) ->
1302+ force_load_table_when_loader_aborts (Config , ext_disc_only_copies ).
1303+
1304+ force_load_table_when_loader_aborts (Config , Storage ) ->
1305+ [Node1 , Node2 ] = Nodes = ? acquire_nodes (2 , Config ),
1306+ Table = ? FUNCTION_NAME ,
1307+ Populate = fun (F , N ) when N > 0 ->
1308+ mnesia :write ({Table , N , []}),
1309+ F (F , N - 1 );
1310+ (_F , _N ) ->
1311+ ok
1312+ end ,
1313+ ? match ({atomic , ok }, mnesia :create_table (Table , [{Storage , Nodes }])),
1314+ ? match ({atomic , ok }, mnesia :transaction (fun () -> Populate (Populate , 1_000_000 ) end )),
1315+ ? match (ok , mnesia :set_master_nodes ([Node2 ])),
1316+ ? match (stopped , mnesia :stop ()),
1317+ ? match (ok , mnesia :start ()),
1318+ ? match (ok , mnesia_test_lib :block_peer (Node1 , Node2 )),
1319+ ? match ({timeout , [Table ]}, mnesia :wait_for_tables ([Table ], 0 )),
1320+ ? match (pang , net_adm :ping (Node2 )),
1321+ {Pid , Ref } = spawn_monitor (fun () -> yes = mnesia :force_load_table (Table ) end ),
1322+ receive
1323+ {'DOWN' , Ref , process , Pid , _ } ->
1324+ ok
1325+ after timer :seconds (15 ) ->
1326+ ct :fail (" Pid: ~p stuck in:~n~p~n " ,
1327+ [Pid , process_info (Pid , current_stacktrace )])
1328+ end .
1329+
1330+ force_load_table_when_loader_on_different_pid (Config ) ->
1331+ [Node1 , Node2 ] = Nodes = ? acquire_nodes (2 , Config ),
1332+ Table = ? FUNCTION_NAME ,
1333+ Populate = fun (F , N ) when N > 0 ->
1334+ mnesia :write ({Table , N , []}),
1335+ F (F , N - 1 );
1336+ (_F , _N ) ->
1337+ ok
1338+ end ,
1339+ ? match ({atomic , ok }, mnesia :create_table (Table , [{disc_only_copies , Nodes }])),
1340+ ? match ({atomic , ok }, mnesia :transaction (fun () -> Populate (Populate , 500_000 ) end )),
1341+ ? match (ok , mnesia :set_master_nodes ([Node2 ])),
1342+ ? match (stopped , mnesia :stop ()),
1343+ ? match (ok , mnesia :start ()),
1344+ ? match (ok , mnesia_test_lib :block_peer (Node1 , Node2 )),
1345+ ? match ({timeout , [Table ]}, mnesia :wait_for_tables ([Table ], 0 )),
1346+ ? match (pang , net_adm :ping (Node2 )),
1347+ ? match (ok , timer :sleep (timer :seconds (1 ))),
1348+ {Pid , Ref } = spawn_monitor (fun () -> yes = mnesia :force_load_table (Table ) end ),
1349+ receive
1350+ {'DOWN' , Ref , process , Pid , _ } ->
1351+ ok
1352+ after timer :seconds (15 ) ->
1353+ ct :fail (" Pid: ~p stuck in:~n~p~n " ,
1354+ [Pid , [process_info (dets_server :get_pid (Table ), K ) ||
1355+ K <- [monitored_by , current_stacktrace ]]])
1356+ end .
1357+
12731358% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12741359
12751360
0 commit comments