Bugzilla – Attachment 135560 Details for
Bug 29325
commit_file.pl error 'Already in a transaction'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29325: Handle the transaction in BatchCommitRecords
Bug-29325-Handle-the-transaction-in-BatchCommitRec.patch (text/plain), 3.07 KB, created by
Nick Clemens (kidclamp)
on 2022-06-01 20:00:31 UTC
(
hide
)
Description:
Bug 29325: Handle the transaction in BatchCommitRecords
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-06-01 20:00:31 UTC
Size:
3.07 KB
patch
obsolete
>From 4b0f2ca2b42f11e84861a9d25e9acc7e842c4cca Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 1 Jun 2022 19:57:14 +0000 >Subject: [PATCH] Bug 29325: Handle the transaction in BatchCommitRecords > >Requiring the callback to commit was breaking reversion, and likely elsewhere > >Let's simplify and say that the routine iteself will handle the txn and commit > >TO test: >1 - Stage a file >2 - Import a file >3 - Revert a file >4 - Test staff client and command line > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/ImportBatch.pm | 10 ++++------ > misc/commit_file.pl | 1 - > tools/manage-marc-import.pl | 4 +--- > 3 files changed, 5 insertions(+), 10 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 428f8e039d..eef4fbcdab 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -612,18 +612,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') { >@@ -749,7 +747,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 threshhold > $sth->finish(); > > if ( @biblio_ids ) { >diff --git a/misc/commit_file.pl b/misc/commit_file.pl >index 2e404e7e3c..da504d2a3a 100755 >--- a/misc/commit_file.pl >+++ b/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 { >diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl >index a75f8c8581..c0491f428d 100755 >--- a/tools/manage-marc-import.pl >+++ b/tools/manage-marc-import.pl >@@ -275,7 +275,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, >@@ -338,9 +338,7 @@ sub progress_callback { > my $job = shift; > return sub { > my $progress = shift; >- my $schema = shift; > $job->progress($progress); >- $schema->txn_commit; > } > } > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29325
:
126944
|
127489
|
128033
|
135556
|
135557
|
135558
|
135559
|
135560
|
136390
|
136391
|
136392
|
136393
|
136394
|
136398
|
136399
|
136400
|
136401
|
136402
|
136478
|
136479
|
136480
|
136481
|
136482
|
136496
|
136497
|
136531
|
136803