Bugzilla – Attachment 161756 Details for
Bug 35819
"No job found" error for BatchUpdateBiblioHoldsQueue (race condition)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35819: Adjust es_indexer_daemon
Bug-35819-Adjust-esindexerdaemon.patch (text/plain), 3.58 KB, created by
Marcel de Rooy
on 2024-02-05 11:27:06 UTC
(
hide
)
Description:
Bug 35819: Adjust es_indexer_daemon
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2024-02-05 11:27:06 UTC
Size:
3.58 KB
patch
obsolete
>From e892dbde4827f5c2c7ce04b2e181a06403600df4 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 30 Jan 2024 09:30:38 +0100 >Subject: [PATCH] Bug 35819: Adjust es_indexer_daemon >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >[EDIT] Add forgotten module >--- > misc/workers/es_indexer_daemon.pl | 45 +++++++++++++++++++++++++------ > 1 file changed, 37 insertions(+), 8 deletions(-) > >diff --git a/misc/workers/es_indexer_daemon.pl b/misc/workers/es_indexer_daemon.pl >index 44bcdbf9a5..5f34345391 100755 >--- a/misc/workers/es_indexer_daemon.pl >+++ b/misc/workers/es_indexer_daemon.pl >@@ -56,6 +56,7 @@ use Try::Tiny; > use Pod::Usage; > use Getopt::Long; > use List::MoreUtils qw( natatime ); >+use Time::HiRes; > > use C4::Context; > use Koha::Logger; >@@ -65,6 +66,10 @@ use Koha::SearchEngine::Indexer; > > > my ( $help, $batch_size ); >+ >+my $not_found_retries = {}; >+my $max_retries = $ENV{MAX_RETRIES} || 10; >+ > GetOptions( > 'h|help' => \$help, > 'b|batch_size=s' => \$batch_size >@@ -116,22 +121,46 @@ while (1) { > my $body = $frame->body; > decode_json($body); # TODO Should this be from_json? Check utf8 flag. > } catch { >- $logger->warn(sprintf "Frame not processed - %s", $_); >+ Koha::Logger->get({ interface => 'worker' })->warn(sprintf "Frame not processed - %s", $_); > return; >- } finally { >- $conn->ack( { frame => $frame } ); > }; > >- next unless $args; >+ 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->find( $args->{job_id} ); > >- # FIXME This means we need to have create the DB entry before >- # It could work in a first step, but then we will want to handle job that will be created from the message received >- my $job = Koha::BackgroundJobs->search( { id => $args->{job_id}, status => 'new' } )->next; >+ if ( $job && $job->status ne 'new' ) { >+ Koha::Logger->get( { interface => 'worker' } ) >+ ->warn( sprintf "Job %s has wrong status %s", $args->{job_id}, $job->status ); >+ >+ # nack without requeue, we do not want to process this frame again >+ $conn->nack( { frame => $frame, requeue => 'false' } ); >+ next; >+ } > > unless ($job) { >- $logger->warn( sprintf "Job %s not found, or has wrong status", $args->{job_id} ); >+ if ( ++$not_found_retries->{$args->{job_id}} >= $max_retries ) { >+ Koha::Logger->get( { interface => 'worker' } ) >+ ->warn( sprintf "Job %s not found, no more retry", $args->{job_id} ); >+ >+ # nack without requeue, we do not want to process this frame again >+ $conn->nack( { frame => $frame, requeue => 'false' } ); >+ next; >+ } >+ >+ Koha::Logger->get( { interface => 'worker' } ) >+ ->debug( sprintf "Job %s not found, will retry later", $args->{job_id} ); >+ >+ # nack to force requeue >+ $conn->nack( { frame => $frame, requeue => 'true' } ); >+ Time::HiRes::sleep(0.5); > next; > } >+ $conn->ack( { frame => $frame } ); > > push @jobs, $job; > if ( @jobs >= $batch_size || !$conn->can_read( { timeout => '0.1' } ) ) { >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35819
:
161067
|
161071
|
161139
|
161172
|
161173
|
161267
|
161527
|
161624
|
161682
|
161683
|
161684
|
161685
|
161686
|
161752
|
161753
|
161754
|
161755
| 161756 |
161757