25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Fix transaction aborting and restarting in ejabberd_sql

This commit is contained in:
Alexey Shchepin 2019-03-07 22:14:13 +03:00
parent a4222fe9b3
commit e921b43754

View File

@ -524,6 +524,7 @@ outer_transaction(F, NRestarts, _Reason) ->
catch
?EX_RULE(throw, {aborted, Reason}, _) when NRestarts > 0 ->
sql_query_internal([<<"rollback;">>]),
put(?NESTING_KEY, ?TOP_LEVEL_TXN),
outer_transaction(F, NRestarts - 1, Reason);
?EX_RULE(throw, {aborted, Reason}, Stack) when NRestarts =:= 0 ->
?ERROR_MSG("SQL transaction restarts exceeded~n** "
@ -610,6 +611,7 @@ sql_query_internal(#sql_query{} = Query) ->
check_error(Res, Query);
sql_query_internal(F) when is_function(F) ->
case catch execute_fun(F) of
{aborted, Reason} -> {error, Reason};
{'EXIT', Reason} -> {error, Reason};
Res -> Res
end;