Skip to content

Commit

Permalink
Merge pull request #9357 from rabbitmq/mergify/bp/v3.12.x/pr-9356
Browse files Browse the repository at this point in the history
Improve consumer metric cleanup when a channel goes down (backport #9356)
  • Loading branch information
michaelklishin authored Sep 9, 2023
2 parents d53be96 + a5c9ca1 commit ce08775
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deps/rabbit/src/rabbit_amqqueue_process.erl
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ handle_ch_down(DownPid, State = #q{consumers = Consumers,
{ok, State1};
{ChAckTags, ChCTags, Consumers1} ->
QName = qname(State1),
[emit_consumer_deleted(DownPid, CTag, QName, ?INTERNAL_USER) || CTag <- ChCTags],
[rabbit_core_metrics:consumer_deleted(DownPid, CTag, QName) || CTag <- ChCTags],
Holder1 = new_single_active_consumer_after_channel_down(DownPid, Holder, SingleActiveConsumerOn, Consumers1),
State2 = State1#q{consumers = Consumers1,
active_consumer = Holder1},
Expand Down
12 changes: 12 additions & 0 deletions deps/rabbitmq_management_agent/src/rabbit_mgmt_metrics_gc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,18 @@ delete_samples(Table, Id, Intervals) ->
[ets:delete(Table, {Id, I}) || I <- Intervals],
ok.

index_delete(consumer_stats = Table, channel = Type, Id) ->
IndexTable = rabbit_mgmt_metrics_collector:index_table(Table, Type),
MatchPattern = {'_', Id, '_'},
%% Delete consumer_stats_queue_index
ets:match_delete(consumer_stats_queue_index,
{'_', MatchPattern}),
%% Delete consumer_stats
ets:match_delete(consumer_stats,
{MatchPattern,'_'}),
%% Delete consumer_stats_channel_index
ets:delete(IndexTable, Id),
ok;
index_delete(Table, Type, Id) ->
IndexTable = rabbit_mgmt_metrics_collector:index_table(Table, Type),
Keys = ets:lookup(IndexTable, Id),
Expand Down

0 comments on commit ce08775

Please # to comment.