Skip to content

Commit fc88e3f

Browse files
committed
Log consumer timeout with debug level
Log consumer timeout with warning level the first time, and at debug level subsequently. (cherry picked from commit 048dc9e)
1 parent f8a7449 commit fc88e3f

1 file changed

Lines changed: 22 additions & 16 deletions

File tree

deps/rabbit/src/rabbit_amqp_session.erl

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,8 @@
240240
%% While at_least_one_credit_req_in_flight is true, we stash the
241241
%% latest credit request from the receiving client.
242242
stashed_credit_req :: none | #credit_req{},
243-
%% Whether a consumer timeout warning was already logged for this link.
244-
timeout_logged :: boolean()
243+
%% Consumer timeout log level
244+
timeout_log_level :: warning | debug
245245
}).
246246

247247
-record(outgoing_unsettled, {
@@ -860,15 +860,15 @@ handle_stashed_consumer_timeout(#state{cfg = #cfg{container_id = ContainerId,
860860
fun(CTag, true, Acc) ->
861861
Handle = ctag_to_handle(CTag),
862862
case Acc of
863-
#{Handle := #outgoing_link{timeout_logged = false,
864-
name = LinkName,
865-
queue_name = QName} = Link} ->
866-
?LOG_WARNING(
867-
"released unsettled messages due to consumer timeout on "
868-
"connection '~ts' for link '~ts' with handle ~b to "
869-
"AMQP container '~ts' consuming from ~ts",
870-
[ConnName, LinkName, Handle, ContainerId, rabbit_misc:rs(QName)]),
871-
Acc#{Handle := Link#outgoing_link{timeout_logged = true}};
863+
#{Handle := #outgoing_link{name = LinkName,
864+
queue_name = QName,
865+
timeout_log_level = Level} = Link} ->
866+
?LOG(Level,
867+
"released unsettled messages due to consumer timeout on "
868+
"connection '~ts' for link '~ts' with handle ~b to "
869+
"AMQP container '~ts' consuming from ~ts",
870+
[ConnName, LinkName, Handle, ContainerId, rabbit_misc:rs(QName)]),
871+
Acc#{Handle := Link#outgoing_link{timeout_log_level = debug}};
872872
_ ->
873873
Acc
874874
end
@@ -1629,7 +1629,7 @@ handle_attach(#'v1_0.attach'{role = ?AMQP_ROLE_RECEIVER,
16291629
drain = false},
16301630
at_least_one_credit_req_in_flight = false,
16311631
stashed_credit_req = none,
1632-
timeout_logged = false},
1632+
timeout_log_level = warning},
16331633
OutgoingLinks = OutgoingLinks0#{HandleInt => L},
16341634
State1 = State0#state{queue_states = QStates,
16351635
outgoing_links = OutgoingLinks,
@@ -4151,9 +4151,15 @@ info_outgoing_management_links(Links) ->
41514151
credit = Credit} <- Links].
41524152

41534153
info_outgoing_links(Links) ->
4154-
[info_outgoing_link(Handle, Name, SourceAddress, QueueNameBin,
4155-
SendSettled, MaxMessageSize, Filter,
4156-
DeliveryCount, Credit, ConsumerTimeoutLogged)
4154+
[begin
4155+
ConsumerTimeout = case ConsumerTimeoutLogLevel of
4156+
warning -> false;
4157+
debug -> true
4158+
end,
4159+
info_outgoing_link(Handle, Name, SourceAddress, QueueNameBin,
4160+
SendSettled, MaxMessageSize, Filter,
4161+
DeliveryCount, Credit, ConsumerTimeout)
4162+
end
41574163
|| Handle := #outgoing_link{
41584164
name = Name,
41594165
source_address = SourceAddress,
@@ -4164,7 +4170,7 @@ info_outgoing_links(Links) ->
41644170
client_flow_ctl = #client_flow_ctl{
41654171
delivery_count = DeliveryCount,
41664172
credit = Credit},
4167-
timeout_logged = ConsumerTimeoutLogged}
4173+
timeout_log_level = ConsumerTimeoutLogLevel}
41684174
<- Links].
41694175

41704176
info_outgoing_link(Handle, LinkName, SourceAddress, QueueNameBin, SendSettled,

0 commit comments

Comments
 (0)