Bugzilla – Attachment 145064 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: Remove fork
Bug-32393-Remove-fork.patch (text/plain), 2.34 KB, created by
Jonathan Druart
on 2023-01-05 15:40:06 UTC
(
hide
)
Description:
Bug 32393: Remove fork
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-01-05 15:40:06 UTC
Size:
2.34 KB
patch
obsolete
>From 963701e184ce2c009c62d9b7e65b909e61d6057b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 5 Jan 2023 16:39:27 +0100 >Subject: [PATCH] Bug 32393: Remove fork > >--- > misc/background_jobs_worker.pl | 30 ++++++++++-------------------- > 1 file changed, 10 insertions(+), 20 deletions(-) > >diff --git a/misc/background_jobs_worker.pl b/misc/background_jobs_worker.pl >index 89339d45eea..5c7908ee0a9 100755 >--- a/misc/background_jobs_worker.pl >+++ b/misc/background_jobs_worker.pl >@@ -53,7 +53,6 @@ use Try::Tiny; > use Pod::Usage; > use Getopt::Long; > >-use Koha::Logger; > use Koha::BackgroundJobs; > > my ( $help, @queues ); >@@ -94,46 +93,37 @@ while (1) { > next; # will reconnect automatically > } > >+ if ( $frame->command ne 'MESSAGE' ) { >+ warn "Frame is not a message we should process"; >+ warn $frame->body; >+ next; >+ } >+ > my $job; >+ my $job_id; > 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_id = $args->{job_id}; > $job = Koha::BackgroundJobs->find($args->{job_id}); > >- process_job( $job, $args ); >+ $job->process( $args ); > } catch { > Koha::Logger->get->warn(sprintf "Job and/or frame not processed - %s", $_); > } finally { > $job->status('failed')->store if $job && @_; > $conn->ack( { frame => $frame } ); > }; >- > } else { > my $jobs = Koha::BackgroundJobs->search({ status => 'new', queue => \@queues }); > while ( my $job = $jobs->next ) { > my $args = $job->json->decode($job->data); >- process_job( $job, { job_id => $job->id, %$args } ); >+ $job->process( { job_id => $job->id, %$args } ); > } > sleep 10; > } > } > $conn->disconnect; >- >-sub process_job { >- my ( $job, $args ) = @_; >- >- my $pid; >- if ( $pid = fork ) { >- wait; >- return; >- } >- >- die "fork failed!" unless defined $pid; >- >- $job->process( $args ); >- >- exit; >-} >-- >2.25.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 32393
:
144401
|
144569
|
145064
|
145207
|
145216
|
145217
|
145596
|
145597
|
145598
|
145609
|
145610
|
145611
|
145613
|
145614
|
145615
|
145616