Bug 32250: (follow-up) Commit background job to the DB

We can't run a background job if it isn't in the database, however,
this script runs with AutoCommit disabled. We need to enable it while
generating the background job, then disable for the updates.

I don't nkow if using a transaction would be preferable.

I tried to solve this independently, but it requires consolidating the
index requests to make this work easily

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit bfc1e3c226)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Nick Clemens 2023-04-20 15:53:10 +00:00 committed by Martin Renvoize
parent 1078a907ac
commit 01ec0a33cb
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 4 additions and 1 deletions

View File

@ -111,8 +111,9 @@ sub process_bibs {
}
if ( not $test_only ) {
$indexer->index_records( \@updated_biblios, "specialUpdate", "biblioserver" );
$dbh->commit;
$dbh->{AutoCommit} = 1;
$indexer->index_records( \@updated_biblios, "specialUpdate", "biblioserver" );
}
my $headings_linked = 0;
@ -248,7 +249,9 @@ sub process_bib {
sub print_progress_and_commit {
my $recs = shift;
$dbh->commit();
$dbh->{AutoCommit} = 1;
$indexer->index_records( \@updated_biblios, "specialUpdate", "biblioserver" );
$dbh->{AutoCommit} = 0;
@updated_biblios = ();
print "... processed $recs records\n";
}