Bugzilla – Attachment 117500 Details for
Bug 27756
background_jobs_worker.pl is memory inefficient
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27756: Fork background jobs to prevent memory leak
Bug-27756-Fork-background-jobs-to-prevent-memory-l.patch (text/plain), 1.64 KB, created by
Jonathan Druart
on 2021-03-02 10:24:19 UTC
(
hide
)
Description:
Bug 27756: Fork background jobs to prevent memory leak
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-03-02 10:24:19 UTC
Size:
1.64 KB
patch
obsolete
>From 4205d009a87ed586466ba31a9b38d09cec986ccb Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 2 Mar 2021 11:22:29 +0100 >Subject: [PATCH] Bug 27756: Fork background jobs to prevent memory leak > >--- > misc/background_jobs_worker.pl | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) > >diff --git a/misc/background_jobs_worker.pl b/misc/background_jobs_worker.pl >index 0520189fa5..5d409cdf1b 100755 >--- a/misc/background_jobs_worker.pl >+++ b/misc/background_jobs_worker.pl >@@ -51,16 +51,32 @@ 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->find($args->{job_id}); >- my $success = $job->process( $args ); > >- $conn->ack( { frame => $frame } ); # FIXME depending on $success? >+ process_job( $job, $args ); >+ $conn->ack( { frame => $frame } ); # FIXME depending on success? >+ > } else { > my $jobs = Koha::BackgroundJobs->search({ status => 'new' }); > while ( my $job = $jobs->next ) { > my $args = decode_json($job->data); >- $job->process( { job_id => $job->id, %$args } ); >+ process_job( $job, { 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.20.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 27756
:
117500
|
119625
|
120661