Bug 35819: nack and not requeue if frame is invalid

If a frame cannot be correctly processed (most probably because the body
is not valid JSON) then we are not acking or nacking the frame and the
worker is stuck.

In this specific case we should nack without requeuing the frame.

NOTE that requeue must be 'true' or 'false', not 1 or 0, or the default
'true' will be used.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 8394092568)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit 87e3d35e84)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2024-01-23 10:14:21 +01:00 committed by Lucas Gass
parent 8dad4e970b
commit 5fa868614e
1 changed files with 15 additions and 15 deletions

View File

@ -125,24 +125,24 @@ while (1) {
return;
};
my $job;
if ($args) {
$job = Koha::BackgroundJobs->search( { id => $args->{job_id}, status => 'new' } )->next;
unless ($job) {
Koha::Logger->get( { interface => 'worker' } )
->warn( sprintf "Job %s not found, or has wrong status", $args->{job_id} );
# nack to force requeue
$conn->nack( { frame => $frame, requeue => 1 } );
Time::HiRes::sleep(0.5);
next;
}
$conn->ack( { frame => $frame } );
} else {
unless ( $args ) {
Koha::Logger->get({ interface => 'worker' })->warn(sprintf "Frame does not have correct args, ignoring it");
$conn->nack( { frame => $frame, requeue => 'false' } );
next;
}
my $job = Koha::BackgroundJobs->search( { id => $args->{job_id}, status => 'new' } )->next;
unless ($job) {
Koha::Logger->get( { interface => 'worker' } )
->warn( sprintf "Job %s not found, or has wrong status", $args->{job_id} );
# nack to force requeue
$conn->nack( { frame => $frame, requeue => 'true' } );
Time::HiRes::sleep(0.5);
next;
}
$conn->ack( { frame => $frame } );
$pm->start and next;
srand(); # ensure each child process begins with a new seed
process_job( $job, $args );