Bugzilla – Attachment 161624 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.24 KB, created by
Jonathan Druart
on 2024-01-30 08:31:02 UTC
(
hide
)
Description:
Bug 35819: Adjust es_indexer_daemon
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-01-30 08:31:02 UTC
Size:
3.24 KB
patch
obsolete
>From 4f6407c80fb73d2a01476e07f6716da67fb31234 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 > >--- > misc/workers/es_indexer_daemon.pl | 44 +++++++++++++++++++++++++------ > 1 file changed, 36 insertions(+), 8 deletions(-) > >diff --git a/misc/workers/es_indexer_daemon.pl b/misc/workers/es_indexer_daemon.pl >index 44bcdbf9a53..2c5ae34a1b8 100755 >--- a/misc/workers/es_indexer_daemon.pl >+++ b/misc/workers/es_indexer_daemon.pl >@@ -65,6 +65,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 +120,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.34.1
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