LP#1953057: improve reset-after-crash handling for Perl apps user/gmcharlt/lp1953057_forcibly_reap_after_reset
authorGalen Charlton <gmc@equinoxOLI.org>
Thu, 2 Dec 2021 16:48:48 +0000 (11:48 -0500)
committerGalen Charlton <gmc@equinoxOLI.org>
Thu, 2 Dec 2021 16:55:35 +0000 (11:55 -0500)
commita55887ef21ea2c9a699810a672f5b7cb88deb884
tree30f5df3f559e9d55257abaae86e5a8bc32836745
parent04524df6e341c47dd9ddd6e617b5d66f313b6b01
LP#1953057: improve reset-after-crash handling for Perl apps

This patch more forcibly reaps children and resets the active
and idle lists after an uncaught exception in the main run
method triggers a reset of the service. This avoids an issue
where such a reset would result in the listener thinking it
has more running drones than is actually the case, which can
make it think it's hit max_children limits sooner than is actually
the case.

To test
-------
[1] Do something to arrange for a busy Perl service to throw
    an exception in the listener, such as setting up a replication
    of bug 1953044 or adding code to cause the listener to randomly
    throw an exception.
[2] Observe that the listener does not fully clean up the drones
    it has at the point of the crash, and consequently may think
    post-reset that it is closer to the max_children limit than
    is actually the case. One symptom of this is requests getting
    added to the backlog queue unecessarily.
[3] Apply the patch and repeat step 1. This time, the service should
    reset itself properly and handle requests and drones post-reset
    as expected.

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
src/perl/lib/OpenSRF/Server.pm