Bug 27151 - SIP2 server doesn't handle broken connections which then kills SIP2 server
Summary: SIP2 server doesn't handle broken connections which then kills SIP2 server
Status: CLOSED INVALID
Alias: None
Product: Koha
Classification: Unclassified
Component: SIP2 (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-04 10:52 UTC by Joonas Kylmälä
Modified: 2022-06-06 20:24 UTC (History)
8 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joonas Kylmälä 2020-12-04 10:52:32 UTC
Koha SIP2 server doesn't handle the situation where a client unexpectedly closes socket, this leads to the SIP2 server processes being killed and therefore SIP2 service being unavailable.

sip-error.log when this happens:
koha3-koha-sip: client (pid 1181) killed by signal 13, stopping  

More info on this issue I found from the perl website manual (https://perldoc.perl.org/perlipc):

"Be careful to check the return values from both open() and close(). If you're writing to a pipe, you should also trap SIGPIPE. [...]"

Another problem we have is that the koha-common service doesn't start the process if it gets killed, but let's focus here only on the SIGPIPE issue.

This has happened now 2 times in around 1 month period on our Koha SIP instances.
Comment 1 Jonathan Druart 2020-12-09 12:39:48 UTC
Would the following change work?

diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm
index 8d5be71624..36d7606b0b 100644
--- a/C4/SIP/SIPServer.pm
+++ b/C4/SIP/SIPServer.pm
@@ -28,6 +28,8 @@ use base qw(Net::Server::PreFork);
 
 use constant LOG_SIP => "local6"; # Local alias for the logging facility
 
+$SIG{PIPE} = "IGNORE";
+
 #
 # Main  # not really, since package SIPServer
 #
Comment 2 Jonathan Druart 2021-01-07 14:12:44 UTC
Joonas, by any chances, did you try what I suggested in the previous comment?
Comment 3 Joonas Kylmälä 2021-01-07 14:30:06 UTC
(In reply to Jonathan Druart from comment #2)
> Joonas, by any chances, did you try what I suggested in the previous comment?

I have not tried it but it should fix the problem at least cosmetically. I need to investigate what side effects it will have first if any, for example whether it will cause a process to hang and when there is a max sip server processes defined will we run out of those after a period of time.
Comment 4 Joonas Kylmälä 2021-05-14 07:06:08 UTC
This hasn't happened in a long time and I don't know if it happens anymore with latest master. I think this could be closed.