]> granicus.if.org Git - ejabberd/commitdiff
Fix transaction aborting and restarting in ejabberd_sql
authorAlexey Shchepin <alexey@process-one.net>
Thu, 7 Mar 2019 19:14:13 +0000 (22:14 +0300)
committerAlexey Shchepin <alexey@process-one.net>
Thu, 7 Mar 2019 19:14:13 +0000 (22:14 +0300)
src/ejabberd_sql.erl

index c891e7aa828077949bd948649464b0adc31cba92..a02aece4d4739b14e5631d951b4c4c0367d33d55 100644 (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;