From: Bill Erickson Date: Wed, 17 May 2023 15:48:13 +0000 (-0400) Subject: LPXXX Avoid logging dupe NOT CONNECTED errors X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fberick%2Flpxxx-no-repeat-not-connected;p=working%2FOpenSRF.git LPXXX Avoid logging dupe NOT CONNECTED errors Signed-off-by: Bill Erickson --- diff --git a/src/perl/lib/OpenSRF/Transport.pm b/src/perl/lib/OpenSRF/Transport.pm index 5aeff4d..27aa59d 100644 --- a/src/perl/lib/OpenSRF/Transport.pm +++ b/src/perl/lib/OpenSRF/Transport.pm @@ -66,6 +66,17 @@ the handler method on the message document. =cut +# Track remote-id's / addresses for clients which sent us a request, but +# are no longer connected to the message bus. In cases where a client +# goes away during an API call that produces many responses, the "not +# connected" error logs below will repeat per response, which could be +# quite a bit of repititive logging. +# +# We could track this as session-level information instead, but the +# assumption is that this list will not grow large unless your system is +# already unusable. +my %lost_callers; + sub handler { my $start_time = time(); my( $class, $service, $data ) = @_; @@ -79,11 +90,16 @@ sub handler { $logger->set_osrf_xid($data->osrf_xid); + if (defined($type) and $type eq 'error') { + if ($lost_callers{$remote_id}) { + # We've already raised an exception and logged a warning about + # this caller disappearing. + return 0; + } - if (defined($type) and $type eq 'error') { - throw OpenSRF::EX::Session ("$remote_id IS NOT CONNECTED TO THE NETWORK!!!"); - - } + $lost_callers{$remote_id} = 1; + throw OpenSRF::EX::Session ("$remote_id IS NOT CONNECTED TO THE NETWORK!!!"); + } # See if the app_session already exists. If so, make # sure the sender hasn't changed if we're a server