fix(kafka): improve shutdown and health check logs during shutdown
This commit is contained in:
parent
5df7314255
commit
0ca3f51503
|
@ -381,7 +381,13 @@ start_consumer(Config, ResourceId, ClientID) ->
|
|||
stop_subscriber(SubscriberId) ->
|
||||
_ = log_when_error(
|
||||
fun() ->
|
||||
try
|
||||
emqx_bridge_kafka_consumer_sup:ensure_child_deleted(SubscriberId)
|
||||
catch
|
||||
exit:{noproc, _} ->
|
||||
%% may happen when node is shutting down
|
||||
ok
|
||||
end
|
||||
end,
|
||||
#{
|
||||
msg => "failed_to_delete_kafka_subscriber",
|
||||
|
@ -465,6 +471,7 @@ do_get_topic_status(ClientID, KafkaTopic, SubscriberId, NPartitions) ->
|
|||
end.
|
||||
|
||||
are_subscriber_workers_alive(SubscriberId) ->
|
||||
try
|
||||
Children = supervisor:which_children(emqx_bridge_kafka_consumer_sup),
|
||||
case lists:keyfind(SubscriberId, 1, Children) of
|
||||
false ->
|
||||
|
@ -475,6 +482,11 @@ are_subscriber_workers_alive(SubscriberId) ->
|
|||
%% node, as the group might be spread across an emqx
|
||||
%% cluster.
|
||||
lists:all(fun is_process_alive/1, maps:values(Workers))
|
||||
end
|
||||
catch
|
||||
exit:{shutdown, _} ->
|
||||
%% may happen if node is shutting down
|
||||
false
|
||||
end.
|
||||
|
||||
log_when_error(Fun, Log) ->
|
||||
|
|
|
@ -335,6 +335,7 @@ init_per_testcase(TestCase, Config) ->
|
|||
common_init_per_testcase(TestCase, Config0) ->
|
||||
ct:timetrap(timer:seconds(60)),
|
||||
delete_all_bridges(),
|
||||
emqx_config:delete_override_conf_files(),
|
||||
KafkaTopic =
|
||||
<<
|
||||
(atom_to_binary(TestCase))/binary,
|
||||
|
|
Loading…
Reference in New Issue