fix(emqx_resource): fix crash while flushing queue
We used next_event for flushing the queue in emqx_resource, but this leads to a crash. We now call flush_worker/1 instead.
This commit is contained in:
parent
fbfd4a2565
commit
9d20431257
|
@ -583,10 +583,11 @@ do_flush(
|
|||
),
|
||||
case queue_count(Q1) > 0 of
|
||||
true ->
|
||||
{keep_state, Data1, [{next_event, internal, flush}]};
|
||||
flush_worker(self());
|
||||
false ->
|
||||
ok
|
||||
end,
|
||||
{keep_state, Data1}
|
||||
end
|
||||
end;
|
||||
do_flush(Data0, #{
|
||||
is_batch := true,
|
||||
|
@ -659,15 +660,17 @@ do_flush(Data0, #{
|
|||
}
|
||||
),
|
||||
CurrentCount = queue_count(Q1),
|
||||
Data2 =
|
||||
case {CurrentCount > 0, CurrentCount >= BatchSize} of
|
||||
{false, _} ->
|
||||
{keep_state, Data1};
|
||||
Data1;
|
||||
{true, true} ->
|
||||
{keep_state, Data1, [{next_event, internal, flush}]};
|
||||
flush_worker(self()),
|
||||
Data1;
|
||||
{true, false} ->
|
||||
Data2 = ensure_flush_timer(Data1),
|
||||
ensure_flush_timer(Data1)
|
||||
end,
|
||||
{keep_state, Data2}
|
||||
end
|
||||
end.
|
||||
|
||||
batch_reply_caller(Id, BatchResult, Batch, QueryOpts) ->
|
||||
|
|
Loading…
Reference in New Issue