فهرست منبع

fix(ds): reply sync callers after raft store failure

Thales Macedo Garitezi 1 سال پیش
والد
کامیت
68af211130
1فایلهای تغییر یافته به همراه5 افزوده شده و 1 حذف شده
  1. 5 1
      apps/emqx_durable_storage/src/emqx_ds_replication_layer_egress.erl

+ 5 - 1
apps/emqx_durable_storage/src/emqx_ds_replication_layer_egress.erl

@@ -175,7 +175,11 @@ do_flush(
                 #{db => DB, shard => Shard, reason => Error}
             ),
             Cooldown = ?COOLDOWN_MIN + rand:uniform(?COOLDOWN_MAX - ?COOLDOWN_MIN),
-            ok = timer:sleep(Cooldown)
+            ok = timer:sleep(Cooldown),
+            %% Since we drop the entire batch here, we at least reply callers with an
+            %% error so they don't hang indefinitely in the `gen_server' call with
+            %% `infinity' timeout.
+            lists:foreach(fun(From) -> gen_server:reply(From, {error, Error}) end, Replies)
     end,
     S#s{
         n = 0,