Bugzilla – Attachment 145614 Details for
Bug 32393
background job worker explodes if JSON is incorrect
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32393: Split into 2 try catch blocks
Bug-32393-Split-into-2-try-catch-blocks.patch (text/plain), 2.53 KB, created by
Marcel de Rooy
on 2023-01-24 13:52:34 UTC
(
hide
)
Description:
Bug 32393: Split into 2 try catch blocks
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-01-24 13:52:34 UTC
Size:
2.53 KB
patch
obsolete
>From b88f226b5bedd326255c37986654c4c311f90ba1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 11 Jan 2023 12:36:42 +0100 >Subject: [PATCH] Bug 32393: Split into 2 try catch blocks >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > misc/background_jobs_worker.pl | 33 +++++++++++++++++++++------------ > 1 file changed, 21 insertions(+), 12 deletions(-) > >diff --git a/misc/background_jobs_worker.pl b/misc/background_jobs_worker.pl >index 6bbc82bc08..059d7069ba 100755 >--- a/misc/background_jobs_worker.pl >+++ b/misc/background_jobs_worker.pl >@@ -94,23 +94,28 @@ while (1) { > next; # will reconnect automatically > } > >- my $job; >- try { >+ my $args = try { > my $body = $frame->body; >- my $args = decode_json($body); # TODO Should this be from_json? Check utf8 flag. >- >- # 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 >- $job = Koha::BackgroundJobs->find($args->{job_id}); >- >- process_job( $job, $args ); >+ decode_json($body); # TODO Should this be from_json? Check utf8 flag. > } catch { >- Koha::Logger->get->warn(sprintf "Job and/or frame not processed - %s", $_); >+ Koha::Logger->get->warn(sprintf "Frame not processed - %s", $_); > } finally { >- $job->status('failed')->store if $job && @_; > $conn->ack( { frame => $frame } ); > }; > >+ next unless $args; >+ >+ # 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->find($args->{job_id}); >+ >+ unless ( $job ) { >+ Koha::Logger->get->warn(sprintf "No job found for id=%s", $args->{job_id}); >+ next; >+ } >+ >+ process_job( $job, $args ); >+ > } else { > my $jobs = Koha::BackgroundJobs->search({ status => 'new', queue => \@queues }); > while ( my $job = $jobs->next ) { >@@ -133,7 +138,11 @@ sub process_job { > > die "fork failed!" unless defined $pid; > >- $job->process( $args ); >+ try { >+ $job->process( $args ); >+ } catch { >+ $job->status('failed')->store; >+ }; > > exit; > } >-- >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 32393
:
144401
|
144569
|
145064
|
145207
|
145216
|
145217
|
145596
|
145597
|
145598
|
145609
|
145610
|
145611
|
145613
| 145614 |
145615
|
145616