@@ -713,26 +713,32 @@ terminate(_Reason,
713713 State = # ch {cfg = # conf {user = # user {username = Username }},
714714 consumer_mapping = CM ,
715715 queue_states = QueueCtxs }) ->
716- rabbit_queue_type :close (QueueCtxs ),
717- {_Res , _State1 } = notify_queues (State ),
718- pg_local :leave (rabbit_channels , self ()),
719- rabbit_event :if_enabled (State , # ch .stats_timer ,
720- fun () -> emit_stats (State ) end ),
721- [delete_stats (Tag ) || {Tag , _ } <- get ()],
722- maybe_decrease_global_publishers (State ),
723- maps :foreach (
724- fun (_ , _ ) ->
725- rabbit_global_counters :consumer_deleted (amqp091 )
726- end , CM ),
727- rabbit_core_metrics :channel_closed (self ()),
728- rabbit_event :notify (channel_closed , [{pid , self ()},
729- {user_who_performed_action , Username },
730- {consumer_count , maps :size (CM )}]),
731- case rabbit_confirms :size (State # ch .unconfirmed ) of
732- 0 -> ok ;
733- NumConfirms ->
734- ? LOG_WARNING (" Channel is stopping with ~b pending publisher confirms" ,
735- [NumConfirms ])
716+ try
717+ rabbit_queue_type :close (QueueCtxs ),
718+ {_Res , _State1 } = notify_queues (State ),
719+ pg_local :leave (rabbit_channels , self ()),
720+ rabbit_event :if_enabled (State , # ch .stats_timer ,
721+ fun () -> emit_stats (State ) end ),
722+ [delete_stats (Tag ) || {Tag , _ } <- get ()],
723+ maybe_decrease_global_publishers (State ),
724+ maps :foreach (
725+ fun (_ , _ ) ->
726+ rabbit_global_counters :consumer_deleted (amqp091 )
727+ end , CM ),
728+ rabbit_core_metrics :channel_closed (self ()),
729+ rabbit_event :notify (channel_closed , [{pid , self ()},
730+ {user_who_performed_action , Username },
731+ {consumer_count , maps :size (CM )}]),
732+ case rabbit_confirms :size (State # ch .unconfirmed ) of
733+ 0 -> ok ;
734+ NumConfirms ->
735+ ? LOG_WARNING (" Channel is stopping with ~b pending publisher confirms" ,
736+ [NumConfirms ])
737+ end
738+ catch
739+ _Class :Reason ->
740+ ? LOG_WARNING (" Channel ~tp termination cleanup failed with reason: ~tp " ,
741+ [self (), Reason ])
736742 end .
737743
738744code_change (_OldVsn , State , _Extra ) ->
0 commit comments