Просмотр исходного кода

fix(ft-s3): rely on asynchronous upload abort

So that upload aborts would not block assemblers. This should not
affect the expected behavior since S3 API usually allows having
concurrent uploads, plus we couldn't really guarantee successful aborts
anyway.
Andrew Mayorov 2 лет назад
Родитель
Сommit
3d428a2e0e

+ 2 - 1
apps/emqx_ft/src/emqx_ft_storage_exporter_s3.erl

@@ -94,7 +94,8 @@ complete(#{pid := Pid} = _ExportSt, _Checksum) ->
 -spec discard(export_st()) ->
     ok.
 discard(#{pid := Pid} = _ExportSt) ->
-    emqx_s3_uploader:abort(Pid).
+    % NOTE: will abort upload asynchronously if needed
+    emqx_s3_uploader:shutdown(Pid).
 
 -spec list(options(), query()) ->
     {ok, page(exportinfo())} | {error, term()}.

+ 8 - 1
apps/emqx_s3/src/emqx_s3_uploader.erl

@@ -18,7 +18,9 @@
     complete/2,
 
     abort/1,
-    abort/2
+    abort/2,
+
+    shutdown/1
 ]).
 
 -export([
@@ -87,6 +89,11 @@ abort(Pid) ->
 abort(Pid, Timeout) ->
     gen_statem:call(Pid, abort, Timeout).
 
+-spec shutdown(pid()) -> ok.
+shutdown(Pid) ->
+    _ = erlang:exit(Pid, shutdown),
+    ok.
+
 %%--------------------------------------------------------------------
 %% gen_statem callbacks
 %%--------------------------------------------------------------------