From a78b2d84347bc5f0c59c02bfcd78a639d5da3f71 Mon Sep 17 00:00:00 2001 From: Thomas Klausner Date: Thu, 24 Apr 2025 15:01:21 +0000 Subject: [PATCH] Bug 37020: (follow-up): Remove memleak when not using Elasticsearch If using ES, the script will collect the newly created records and biblionumbers in atwo arrays (@search_engine_record, @search_engine_record_ids) and pass that to the indexer when $commitnum records are read. The arrays are cleaned afterwards. BUT: The records and biblionumbers were always stored, even if we're not using Elasticsearch. And as the cleaning of those arrays only happens if we are in fact using ES, all the data is added but never cleaned. This patch fixes this by only storing record and biblionumber if we have an $indexer (i.e. if we're using Elasticsearch). I have no idea though how/if the records are indexed when using Zebra. After applying this patch and importing a large enough file without using Elasticsearch, the RAM usage also stays more or less constant. @Jan, please verify! --- misc/migration_tools/bulkmarcimport.pl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index ca4f8b2bd3..1fe5fafe43 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -535,8 +535,10 @@ RECORD: while () { 1 #@FIXME: Really always updated? ); } - push @search_engine_record_ids, $authid; - push @search_engine_records, $record; + if ($indexer) { + push @search_engine_record_ids, $authid; + push @search_engine_records, $record; + } } else { my ( $biblioitemnumber, $itemnumbers_ref, $errors_ref, $record_id ); @@ -704,8 +706,10 @@ RECORD: while () { my $biblio = Koha::Biblios->find($record_id); $record = $biblio->metadata_record( { embed_items => 1 } ); - push @search_engine_record_ids, $record_id; - push @search_engine_records, $record; + if ($indexer) { + push @search_engine_record_ids, $record_id; + push @search_engine_records, $record; + } } } } -- 2.39.5