|
Lines 538-546
sub BatchCommitRecords {
Link Here
|
| 538 |
$progress_interval = 0 unless ref($progress_callback) eq 'CODE'; |
538 |
$progress_interval = 0 unless ref($progress_callback) eq 'CODE'; |
| 539 |
|
539 |
|
| 540 |
my $schema = Koha::Database->schema; |
540 |
my $schema = Koha::Database->schema; |
| 541 |
$schema->txn_begin; |
|
|
| 542 |
# NOTE: Moved this transaction to the front of the routine. Note that inside the while loop below |
| 543 |
# transactions may be committed and started too again. The final commit is close to the end. |
| 544 |
|
541 |
|
| 545 |
my $record_type; |
542 |
my $record_type; |
| 546 |
my $num_added = 0; |
543 |
my $num_added = 0; |
|
Lines 571-585
sub BatchCommitRecords {
Link Here
|
| 571 |
my @biblio_ids; |
568 |
my @biblio_ids; |
| 572 |
my @updated_ids; |
569 |
my @updated_ids; |
| 573 |
while (my $rowref = $sth->fetchrow_hashref) { |
570 |
while (my $rowref = $sth->fetchrow_hashref) { |
|
|
571 |
$schema->txn_begin; |
| 574 |
$record_type = $rowref->{'record_type'}; |
572 |
$record_type = $rowref->{'record_type'}; |
| 575 |
|
573 |
|
| 576 |
$rec_num++; |
574 |
$rec_num++; |
| 577 |
|
575 |
|
| 578 |
if ($progress_interval and (0 == ($rec_num % $progress_interval))) { |
576 |
if ($progress_interval and (0 == ($rec_num % $progress_interval))) { |
| 579 |
# report progress and commit |
577 |
# report progress |
| 580 |
$schema->txn_commit unless $skip_intermediate_commit; |
|
|
| 581 |
&$progress_callback( $rec_num ); |
578 |
&$progress_callback( $rec_num ); |
| 582 |
$schema->txn_begin unless $skip_intermediate_commit; |
|
|
| 583 |
} |
579 |
} |
| 584 |
if ($rowref->{'status'} eq 'error' or $rowref->{'status'} eq 'imported') { |
580 |
if ($rowref->{'status'} eq 'error' or $rowref->{'status'} eq 'imported') { |
| 585 |
$num_ignored++; |
581 |
$num_ignored++; |
|
Lines 708-713
sub BatchCommitRecords {
Link Here
|
| 708 |
} |
704 |
} |
| 709 |
SetImportRecordStatus($rowref->{'import_record_id'}, 'ignored'); |
705 |
SetImportRecordStatus($rowref->{'import_record_id'}, 'ignored'); |
| 710 |
} |
706 |
} |
|
|
707 |
$schema->txn_commit; |
| 711 |
} |
708 |
} |
| 712 |
|
709 |
|
| 713 |
if ($progress_interval){ |
710 |
if ($progress_interval){ |
|
Lines 718-725
sub BatchCommitRecords {
Link Here
|
| 718 |
|
715 |
|
| 719 |
SetImportBatchStatus($batch_id, 'imported'); |
716 |
SetImportBatchStatus($batch_id, 'imported'); |
| 720 |
|
717 |
|
| 721 |
# final commit should be before Elastic background indexing in order to find job data |
|
|
| 722 |
$schema->txn_commit; |
| 723 |
|
718 |
|
| 724 |
if (@biblio_ids) { |
719 |
if (@biblio_ids) { |
| 725 |
my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
720 |
my $indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
| 726 |
- |
|
|