From 7aa97b161ce585cd41972e4fb253c31030a9689c Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Fri, 8 Mar 2024 07:37:19 +0000 Subject: [PATCH] Bug 33898: Alternative approach with receive frame timeout See bug 33898 comment6. Test plan: Based on comment12: Stage MARC import and manage. Look at the same time to the results of ps aux|grep Z. Verify that the lines with [background_jobs] disappear within 10 seconds. Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Katrin Fischer (cherry picked from commit bc42006019acf17e0c9b7284070e2f776dc77335) Signed-off-by: Fridolin Somers --- misc/workers/background_jobs_worker.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/misc/workers/background_jobs_worker.pl b/misc/workers/background_jobs_worker.pl index 823dbab15c..5b432ec11f 100755 --- a/misc/workers/background_jobs_worker.pl +++ b/misc/workers/background_jobs_worker.pl @@ -73,6 +73,7 @@ my ( $help, @queues ); my $max_processes = $ENV{MAX_PROCESSES}; $max_processes ||= C4::Context->config('background_jobs_worker')->{max_processes} if C4::Context->config('background_jobs_worker'); $max_processes ||= 1; +my $mq_timeout = $ENV{MQ_TIMEOUT} // 10; my $not_found_retries = {}; my $max_retries = $ENV{MAX_RETRIES} || 10; @@ -114,9 +115,10 @@ if ( $conn ) { } while (1) { if ( $conn ) { - my $frame = $conn->receive_frame; + my $frame = $conn->receive_frame( { timeout => $mq_timeout } ); if ( !defined $frame ) { - # maybe log connection problems + # timeout or connection issue? + $pm->reap_finished_children; next; # will reconnect automatically } -- 2.39.5