Bugzilla – Attachment 161067 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: Retry to fetch job if does not enqueued yet
Bug-35819-Retry-to-fetch-job-if-does-not-enqueued-.patch (text/plain), 2.45 KB, created by
Jonathan Druart
on 2024-01-16 15:38:51 UTC
(
hide
)
Description:
Bug 35819: Retry to fetch job if does not enqueued yet
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-01-16 15:38:51 UTC
Size:
2.45 KB
patch
obsolete
>From cbb7568af929af12fd8cd3dca708427068c40114 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 16 Jan 2024 16:36:05 +0100 >Subject: [PATCH] Bug 35819: Retry to fetch job if does not enqueued yet > >If a job has been enqueued in the middle of a txn, the worker will fetch >the job but fail because it's not in the DB yet. > >The uglier but most effective (as a quick fix and easily backportable >fix) is to... wait a bit. >This patch suggests to sleep 1sec and retry, 10 times. > >It should be enough for the majority of the jobs. >--- > misc/workers/background_jobs_worker.pl | 7 ++++++- > misc/workers/es_indexer_daemon.pl | 7 ++++++- > 2 files changed, 12 insertions(+), 2 deletions(-) > >diff --git a/misc/workers/background_jobs_worker.pl b/misc/workers/background_jobs_worker.pl >index fde3432143a..29647dd3cb4 100755 >--- a/misc/workers/background_jobs_worker.pl >+++ b/misc/workers/background_jobs_worker.pl >@@ -129,7 +129,12 @@ while (1) { > > # 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; >+ my ( $job, $i ); >+ while ( !$job ) { >+ $job = Koha::BackgroundJobs->search( { id => $args->{job_id}, status => 'new' } )->next; >+ sleep 1 unless $job; >+ last if ++$i >= 10; >+ } > > unless( $job ) { > Koha::Logger->get( { interface => 'worker' } ) >diff --git a/misc/workers/es_indexer_daemon.pl b/misc/workers/es_indexer_daemon.pl >index 44bcdbf9a53..800f85ec2f4 100755 >--- a/misc/workers/es_indexer_daemon.pl >+++ b/misc/workers/es_indexer_daemon.pl >@@ -126,7 +126,12 @@ while (1) { > > # 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; >+ my ( $job, $i ); >+ while ( !$job ) { >+ $job = Koha::BackgroundJobs->search( { id => $args->{job_id}, status => 'new' } )->next; >+ sleep 1 unless $job; >+ last if ++$i >= 10; >+ } > > unless ($job) { > $logger->warn( sprintf "Job %s not found, or has wrong status", $args->{job_id} ); >-- >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