Bug 33987: Combine multiple db updates one in BatchCommitRecords
When replacing existing records BatchCommitRecords will the table import_records will be updated three times for three different fields by three different queries. Not only is this inefficient ( especially for large batches ), it seems that this is causing the dreaded "Lock wait timeout exceeded; try restarting transaction" error on some mysql/mariadb configurations. 1) Test plan 2) Download a marc record from Koha 3) Modify the title of that same bib in Koha 4) Stage the downloaded record and overlay the existing record 5) Verify the title has reverted to the original title from the downloaded record! Signed-off-by: Sam Lau <samalau@gmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
30d2ffd295
commit
ab91409f7f
1 changed files with 3 additions and 4 deletions
|
@ -681,14 +681,13 @@ sub BatchCommitRecords {
|
|||
ModAuthority($recordid, $marc_record, GuessAuthTypeCode($marc_record));
|
||||
$query = "UPDATE import_auths SET matched_authid = ? WHERE import_record_id = ?";
|
||||
}
|
||||
my $sth = $dbh->prepare_cached("UPDATE import_records SET marcxml_old = ? WHERE import_record_id = ?");
|
||||
$sth->execute($oldxml, $rowref->{'import_record_id'});
|
||||
# Combine xml update, SetImportRecordOverlayStatus, and SetImportRecordStatus updates into a single update for efficiency, especially in a transaction
|
||||
my $sth = $dbh->prepare_cached("UPDATE import_records SET marcxml_old = ?, status = ?, overlay_status = ? WHERE import_record_id = ?");
|
||||
$sth->execute( $oldxml, 'imported', 'match_applied', $rowref->{'import_record_id'} );
|
||||
$sth->finish();
|
||||
my $sth2 = $dbh->prepare_cached($query);
|
||||
$sth2->execute($recordid, $rowref->{'import_record_id'});
|
||||
$sth2->finish();
|
||||
SetImportRecordOverlayStatus($rowref->{'import_record_id'}, 'match_applied');
|
||||
SetImportRecordStatus($rowref->{'import_record_id'}, 'imported');
|
||||
} elsif ($record_result eq 'ignore') {
|
||||
$recordid = $record_match;
|
||||
$num_ignored++;
|
||||
|
|
Loading…
Reference in a new issue