Bug 35438: Transact each record import separately
When importing a staged file we commit every 50 records For an authority import we are also merging, which can affect many more biblios, and these all end up in the transaction. This can cause tables locks and issues across Koha Test Plan: 1) Apply this patch 2) prove t/db_dependent/ImportBatch.t Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
4d3c838093
commit
74bbb89e99
1 changed files with 3 additions and 8 deletions
|
@ -538,9 +538,6 @@ sub BatchCommitRecords {
|
|||
$progress_interval = 0 unless ref($progress_callback) eq 'CODE';
|
||||
|
||||
my $schema = Koha::Database->schema;
|
||||
$schema->txn_begin;
|
||||
# NOTE: Moved this transaction to the front of the routine. Note that inside the while loop below
|
||||
# transactions may be committed and started too again. The final commit is close to the end.
|
||||
|
||||
my $record_type;
|
||||
my $num_added = 0;
|
||||
|
@ -571,15 +568,14 @@ sub BatchCommitRecords {
|
|||
my @biblio_ids;
|
||||
my @updated_ids;
|
||||
while (my $rowref = $sth->fetchrow_hashref) {
|
||||
$schema->txn_begin;
|
||||
$record_type = $rowref->{'record_type'};
|
||||
|
||||
$rec_num++;
|
||||
|
||||
if ($progress_interval and (0 == ($rec_num % $progress_interval))) {
|
||||
# report progress and commit
|
||||
$schema->txn_commit unless $skip_intermediate_commit;
|
||||
# report progress
|
||||
&$progress_callback( $rec_num );
|
||||
$schema->txn_begin unless $skip_intermediate_commit;
|
||||
}
|
||||
if ($rowref->{'status'} eq 'error' or $rowref->{'status'} eq 'imported') {
|
||||
$num_ignored++;
|
||||
|
@ -708,6 +704,7 @@ sub BatchCommitRecords {
|
|||
}
|
||||
SetImportRecordStatus($rowref->{'import_record_id'}, 'ignored');
|
||||
}
|
||||
$schema->txn_commit;
|
||||
}
|
||||
|
||||
if ($progress_interval){
|
||||
|
@ -718,8 +715,6 @@ sub BatchCommitRecords {
|
|||
|
||||
SetImportBatchStatus($batch_id, 'imported');
|
||||
|
||||
# final commit should be before Elastic background indexing in order to find job data
|
||||
$schema->txn_commit;
|
||||
|
||||
if (@biblio_ids) {
|
||||
my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
|
||||
|
|
Loading…
Reference in a new issue