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
|
case queue_count(Q1) > 0 of
|
||||||
true ->
|
true ->
|
||||||
{keep_state, Data1, [{next_event, internal, flush}]};
|
flush_worker(self());
|
||||||
false ->
|
false ->
|
||||||
{keep_state, Data1}
|
ok
|
||||||
end
|
end,
|
||||||
|
{keep_state, Data1}
|
||||||
end;
|
end;
|
||||||
do_flush(Data0, #{
|
do_flush(Data0, #{
|
||||||
is_batch := true,
|
is_batch := true,
|
||||||
|
@ -659,15 +660,17 @@ do_flush(Data0, #{
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
CurrentCount = queue_count(Q1),
|
CurrentCount = queue_count(Q1),
|
||||||
case {CurrentCount > 0, CurrentCount >= BatchSize} of
|
Data2 =
|
||||||
{false, _} ->
|
case {CurrentCount > 0, CurrentCount >= BatchSize} of
|
||||||
{keep_state, Data1};
|
{false, _} ->
|
||||||
{true, true} ->
|
Data1;
|
||||||
{keep_state, Data1, [{next_event, internal, flush}]};
|
{true, true} ->
|
||||||
{true, false} ->
|
flush_worker(self()),
|
||||||
Data2 = ensure_flush_timer(Data1),
|
Data1;
|
||||||
{keep_state, Data2}
|
{true, false} ->
|
||||||
end
|
ensure_flush_timer(Data1)
|
||||||
|
end,
|
||||||
|
{keep_state, Data2}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
batch_reply_caller(Id, BatchResult, Batch, QueryOpts) ->
|
batch_reply_caller(Id, BatchResult, Batch, QueryOpts) ->
|
||||||
|
|
Loading…
Reference in New Issue