Skip to content

Commit 3057c09

Browse files
committed
Merge branch 'michal/mnesia/restore-stacktrace/OTP-20094' into maint
* michal/mnesia/restore-stacktrace/OTP-20094: Return stacktrace when transaction aborts due to error
2 parents 22a5f20 + a8ca4db commit 3057c09

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

lib/mnesia/src/mnesia_tm.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ execute_transaction(Fun, Args, Factor, Retries, Type) ->
883883
Reason = {aborted, {throw, Value}},
884884
return_abort(Fun, Args, Reason);
885885
error:Reason:ST ->
886-
check_exit(Fun, Args, Factor, Retries, Reason, ST, Type);
886+
check_exit(Fun, Args, Factor, Retries, {Reason, ST}, ST, Type);
887887
exit:{aborted, _R} = Reason:ST ->
888888
check_exit(Fun, Args, Factor, Retries, Reason, ST, Type);
889889
_:Reason:ST ->

lib/mnesia/test/mnesia_trans_access_test.erl

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
create_live_table_index_disc_only/1, del_table_index_ram/1,
4343
del_table_index_disc/1, del_table_index_disc_only/1,
4444
idx_schema_changes_ram/1, idx_schema_changes_disc/1,
45-
idx_schema_changes_disc_only/1]).
45+
idx_schema_changes_disc_only/1, stacktrace_return/1]).
4646

4747
-export([do_nested/1]).
4848

@@ -69,7 +69,7 @@ all() ->
6969
[write, read, wread, delete, delete_object_bag, delete_object_set,
7070
match_object, select, select14, all_keys, transaction, transaction_counters,
7171
{group, nested_activities}, {group, index_tabs},
72-
{group, index_lifecycle}].
72+
{group, index_lifecycle}, stacktrace_return].
7373

7474
groups() ->
7575
[{nested_activities, [],
@@ -1432,3 +1432,27 @@ idx_schema_changes(Config, Storage) ->
14321432
?match([{Tab, 16, 66}], rpc:call(N1, mnesia, dirty_index_read, [Tab, 66, Idx])),
14331433

14341434
?verify_mnesia(Nodes, []).
1435+
1436+
%% Check return value of aborted mnesia:transaction/1
1437+
1438+
stacktrace_return(suite) -> [];
1439+
stacktrace_return(Config) ->
1440+
[_N] = ?acquire_nodes(1, Config),
1441+
Throw = fun() -> throw(test) end,
1442+
Exit = fun() -> exit(test) end,
1443+
Error = fun() -> error(test) end,
1444+
1445+
?match({aborted, {throw, test}}, mnesia:transaction(Throw)),
1446+
?match({aborted, test}, mnesia:transaction(Exit)),
1447+
?match({aborted, {test, [{?MODULE, _, _, _} | _]}}, mnesia:transaction(Error)),
1448+
1449+
Nested = fun(F) ->
1450+
fun() ->
1451+
{aborted, Reason} = mnesia:transaction(F),
1452+
mnesia:abort(Reason)
1453+
end
1454+
end,
1455+
1456+
?match({aborted, {throw, test}}, mnesia:transaction(Nested(Throw))),
1457+
?match({aborted, test}, mnesia:transaction(Nested(Exit))),
1458+
?match({aborted, {test, [{?MODULE, _, _, _} | _]}}, mnesia:transaction(Nested(Error))).

0 commit comments

Comments
 (0)