Bugzilla – Attachment 119625 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.70 KB, created by
Martin Renvoize (ashimema)
on 2021-04-15 13:15:45 UTC
(
hide
)
Description:
Bug 27756: Fork background jobs to prevent memory leak
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-04-15 13:15:45 UTC
Size:
1.70 KB
patch
obsolete
>From ce82bcf5cd6f2f360d3b8f915c6df443237f7590 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 > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > 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