From 9cf3565b986903d1618351a5bb88c623e44a7fd0 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). --- Koha/BackgroundJob.pm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Koha/BackgroundJob.pm b/Koha/BackgroundJob.pm index 09139bdbdd0..aa8cc52fd68 100644 --- a/Koha/BackgroundJob.pm +++ b/Koha/BackgroundJob.pm @@ -24,8 +24,6 @@ use Try::Tiny; 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