Bugzilla – Attachment 142746 Details for
Bug 31561
Background jobs stuck at "New"
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[Do not push] Requeue bg jobs in not found in db
0001-Requeue-bg-job-in-if-not-found-in-db.-Job-may-be-ava.patch (text/plain), 2.19 KB, created by
Björn Nylén
on 2022-10-28 07:42:34 UTC
(
hide
)
Description:
[Do not push] Requeue bg jobs in not found in db
Filename:
MIME Type:
Creator:
Björn Nylén
Created:
2022-10-28 07:42:34 UTC
Size:
2.19 KB
patch
obsolete
>From fd8fbe24fc3dc2af8488d42eff4034149755c050 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Bj=C3=B6rn=20Nyl=C3=A9n?= <bjorn.nylen@ub.lu.se> >Date: Mon, 26 Sep 2022 10:08:08 +0200 >Subject: [PATCH] Requeue bg-job in if not found in db. Job may be available > through RabbitMQ sooner than db. Only try to requeue 100 times to avoid > infinite loop > >--- > misc/background_jobs_worker.pl | 18 ++++++++++++++---- > 1 file changed, 14 insertions(+), 4 deletions(-) > >diff --git a/misc/background_jobs_worker.pl b/misc/background_jobs_worker.pl >index eb36f34f96..78af3a1895 100755 >--- a/misc/background_jobs_worker.pl >+++ b/misc/background_jobs_worker.pl >@@ -48,7 +48,7 @@ The different values available are: > =cut > > use Modern::Perl; >-use JSON qw( decode_json ); >+use JSON qw( decode_json encode_json ); > use Try::Tiny qw( catch try ); > use Pod::Usage; > use Getopt::Long; >@@ -73,7 +73,6 @@ try { > } catch { > warn sprintf "Cannot connect to the message broker, the jobs will be processed anyway (%s)", $_; > }; >- > if ( $conn ) { > # FIXME cf note in Koha::BackgroundJob about $namespace > my $namespace = C4::Context->config('memcached_namespace'); >@@ -96,8 +95,19 @@ while (1) { > # 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->find($args->{job_id}); > >- process_job( $job, $args ); >- $conn->ack( { frame => $frame } ); # FIXME depending on success? >+ if ( $job ) { >+ process_job( $job, $args ); >+ $conn->ack( { frame => $frame } ); # FIXME depending on success? >+ } else { >+ # FIXME if job not found in db, ack this job and requeue as new to retry later >+ $conn->ack( { frame => $frame } ); >+ $args->{retries} = exists $args->{retries} ? $args->{retries} + 1 : 1; >+ if ( $args->{retries} < 100 ) { >+ $conn->send( { destination => $frame->destination , body => encode_json($args) } ); >+ } else { >+ warn "too many attempts, job id: " . $args->{job_id} ; >+ } >+ } > > } else { > my $jobs = Koha::BackgroundJobs->search({ status => 'new', queue => \@queues }); >-- >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 31561
: 142746