From d9e43416bc886081a63ce7a5f04ffe28f1b243a0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 21 May 2021 11:57:20 +0200 Subject: [PATCH] Bug 28413: Reduce background job worker memory footprint It's loading the modules in RAM then forks. Then do not need it to have them loaded in the parent process (the worker/daemon). Signed-off-by: Martin Renvoize --- Koha/BackgroundJob.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index c303fa175ec..7cc8d7e0fd8 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -24,8 +24,6 @@ use Try::Tiny qw( catch try ); use C4::Context; use Koha::DateUtils qw( dt_from_string ); use Koha::Exceptions; -use Koha::BackgroundJob::BatchUpdateBiblio; -use Koha::BackgroundJob::BatchUpdateAuthority; use base qw( Koha::Object ); @@ -151,11 +149,16 @@ sub process { my ( $self, $args ) = @_; my $job_type = $self->type; - return $job_type eq 'batch_biblio_record_modification' - ? Koha::BackgroundJob::BatchUpdateBiblio->process($args) - : $job_type eq 'batch_authority_record_modification' - ? Koha::BackgroundJob::BatchUpdateAuthority->process($args) - : Koha::Exceptions::Exception->throw('->process called without valid job_type'); + + if ( $job_type eq 'batch_biblio_record_modification' ) { + require Koha::BackgroundJob::BatchUpdateBiblio; + Koha::BackgroundJob::BatchUpdateBiblio->process($args) + } elsif ( $job_type eq 'batch_authority_record_modification' ) { + require Koha::BackgroundJob::BatchUpdateAuthority; + Koha::BackgroundJob::BatchUpdateAuthority->process($args) + } else { + Koha::Exceptions::Exception->throw('->process called without valid job_type'); + } } =head3 job_type -- 2.20.1