Bugzilla – Attachment 150101 Details for
Bug 32250
link_bibs_to_authorities generates too many background jobs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32250: Only reindex records when commiting
Bug-32250-Only-reindex-records-when-commiting.patch (text/plain), 2.84 KB, created by
David Nind
on 2023-04-22 21:47:27 UTC
(
hide
)
Description:
Bug 32250: Only reindex records when commiting
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-04-22 21:47:27 UTC
Size:
2.84 KB
patch
obsolete
>From 12955df8a100b0f395c55ab66e8cba312fbbb36a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 13 Jan 2023 20:07:01 +0000 >Subject: [PATCH] Bug 32250: Only reindex records when commiting > >This patch adds an array to catch updated bibs, and defers indexing until a >batch of changes is committed > >To test: >1 - Set LinkerModule system preference to either first or last match > Alternate this between runs of the linker to ensure changes are made >2 - Set SearchEngine to Elasticsearch and reindex (to ensure index is built) >3 - perl misc/link_bibs_to_authorities.pl -v >4 - Check Admin->Jobs and see that many ES index jobs are queued >5 - Apply patch >6 - perl misc/link_bibs_to_authorities.pl -v >7 - Check Admin->Jobs and see that 1 index per commit from is enqueued > >Signed-off-by: David Nind <david@davidnind.com> >--- > misc/link_bibs_to_authorities.pl | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > >diff --git a/misc/link_bibs_to_authorities.pl b/misc/link_bibs_to_authorities.pl >index 981da7f4af..87b8c9feeb 100755 >--- a/misc/link_bibs_to_authorities.pl >+++ b/misc/link_bibs_to_authorities.pl >@@ -17,6 +17,9 @@ use Time::HiRes qw( time ); > use POSIX qw( ceil strftime ); > use Module::Load::Conditional qw( can_load ); > >+use Koha::SearchEngine; >+use Koha::SearchEngine::Indexer; >+ > sub usage { > pod2usage( -verbose => 2 ); > exit; >@@ -75,6 +78,9 @@ my %unlinked_headings; > my %linked_headings; > my %fuzzy_headings; > my $dbh = C4::Context->dbh; >+my @updated_biblios = (); >+my $indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); >+ > $dbh->{AutoCommit} = 0; > process_bibs( $linker, $bib_limit, $auth_limit, $commit, { tagtolink => $tagtolink, allowrelink => $allowrelink }); > $dbh->commit(); >@@ -105,6 +111,7 @@ sub process_bibs { > } > > if ( not $test_only ) { >+ $indexer->index_records( \@updated_biblios, "specialUpdate", "biblioserver" ); > $dbh->commit; > } > >@@ -226,7 +233,12 @@ sub process_bib { > ); > } > if ( not $test_only ) { >- ModBiblio( $record, $biblionumber, $frameworkcode, { disable_autolink => 1, skip_holds_queue => 1 }); >+ ModBiblio( $record, $biblionumber, $frameworkcode, { >+ disable_autolink => 1, >+ skip_holds_queue => 1, >+ skip_record_index =>1 >+ }); >+ push @updated_biblios, $biblionumber; > #Last param is to note ModBiblio was called from linking script and bib should not be linked again > $num_bibs_modified++; > } >@@ -236,6 +248,8 @@ sub process_bib { > sub print_progress_and_commit { > my $recs = shift; > $dbh->commit(); >+ $indexer->index_records( \@updated_biblios, "specialUpdate", "biblioserver" ); >+ @updated_biblios = (); > print "... processed $recs records\n"; > } > >-- >2.30.2
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 32250
:
145305
|
145319
|
149969
|
150100
|
150101
|
150102
|
150239
|
150293
|
150501
|
150502
|
150503
|
150504