@@ -, +, @@ --- C4/ImportBatch.pm | 10 ++++------ misc/commit_file.pl | 1 - tools/manage-marc-import.pl | 4 +--- 3 files changed, 5 insertions(+), 10 deletions(-) --- a/C4/ImportBatch.pm +++ a/C4/ImportBatch.pm @@ -583,18 +583,16 @@ sub BatchCommitRecords { my $rec_num = 0; my @biblio_ids; + $schema->txn_begin; # We commit in a transaction while (my $rowref = $sth->fetchrow_hashref) { $record_type = $rowref->{'record_type'}; - # first record, begin transaction - $schema->txn_begin - unless $rec_num; - $rec_num++; if ($progress_interval and (0 == ($rec_num % $progress_interval))) { # report progress and commit - &$progress_callback($rec_num, $schema); + $schema->txn_commit; + &$progress_callback( $rec_num ); $schema->txn_begin; } if ($rowref->{'status'} eq 'error' or $rowref->{'status'} eq 'imported') { @@ -720,7 +718,7 @@ sub BatchCommitRecords { SetImportRecordStatus($rowref->{'import_record_id'}, 'ignored'); } } - &$progress_callback($rec_num, $schema); # Make sure to commit the final chunk that didn't hit the commit threshhold + $schema->txn_commit; # Commit final records that may not have hit callback threshold $sth->finish(); if ( @biblio_ids ) { --- a/misc/commit_file.pl +++ a/misc/commit_file.pl @@ -129,7 +129,6 @@ _SUMMARY_ sub print_progress_and_commit { my ( $recs, $schema ) = @_; print "... processed $recs records\n"; - $schema->txn_commit; } sub print_usage { --- a/tools/manage-marc-import.pl +++ a/tools/manage-marc-import.pl @@ -277,7 +277,7 @@ sub revert_batch { my $callback = sub { }; if ($runinbackground) { $job = put_in_background($import_batch_id); - $callback = progress_callback( $job, $dbh ); + $callback = progress_callback( $job ); } ( $num_deleted, $num_errors, $num_reverted, @@ -345,9 +345,7 @@ sub progress_callback { my $job = shift; return sub { my $progress = shift; - my $schema = shift; $job->progress($progress); - $schema->txn_commit; } } --