Bugzilla – Attachment 114521 Details for
Bug 27245
bulkmarcimport.pl error 'Already in a transaction'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27245: Replace AutoCommit=0 with txn_begin in bulkmarcimport.pl
Bug-27245-Replace-AutoCommit0-with-txnbegin-in-bul.patch (text/plain), 2.00 KB, created by
Jonathan Druart
on 2020-12-18 13:43:46 UTC
(
hide
)
Description:
Bug 27245: Replace AutoCommit=0 with txn_begin in bulkmarcimport.pl
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-12-18 13:43:46 UTC
Size:
2.00 KB
patch
obsolete
>From 315f8d076b3b99d16bcae307f1ed462b85480283 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 18 Dec 2020 14:41:12 +0100 >Subject: [PATCH] Bug 27245: Replace AutoCommit=0 with txn_begin in > bulkmarcimport.pl > >To prevent >DBD::mysql::db begin_work failed: Already in a transaction at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1588, <GEN45> line 1. > >Test plan: >Export more than 100 records >Use bulkmarcimport (with -commit=10) to import them >Modify a record to make the import fail (for instance having a too long >lccn) >Use bulkmarcimport (with -commit=10) to import them >Notice that the import stops but that the imported record are imported >(a part from the last batch of 10) >--- > misc/migration_tools/bulkmarcimport.pl | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > >diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl >index 80d3396cad..0ae54ee9c1 100755 >--- a/misc/migration_tools/bulkmarcimport.pl >+++ b/misc/migration_tools/bulkmarcimport.pl >@@ -252,13 +252,14 @@ else { > # the SQL query to search on isbn > my $sth_isbn = $dbh->prepare("SELECT biblionumber,biblioitemnumber FROM biblioitems WHERE isbn=?"); > >-$dbh->{AutoCommit} = 0; > my $loghandle; > if ($logfile){ > $loghandle= IO::File->new($logfile, $writemode) ; > print $loghandle "id;operation;status\n"; > } > >+my $schema = Koha::Database->schema; >+$schema->txn_begin; > RECORD: while ( ) { > my $record; > # get records >@@ -537,14 +538,15 @@ RECORD: while ( ) { > } > $yamlhash->{$originalid} = $biblionumber if ($yamlfile); > } >- $dbh->commit() if (0 == $i % $commitnum); >+ if ( 0 == $i % $commitnum ) { >+ $schema->txn_commit; >+ $schema->txn_begin; >+ } > } > print $record->as_formatted()."\n" if ($verbose//0)==2; > last if $i == $number; > } >-$dbh->commit(); >-$dbh->{AutoCommit} = 1; >- >+$schema->txn_commit; > > if ($fk_off) { > $dbh->do("SET FOREIGN_KEY_CHECKS = 1"); >-- >2.20.1
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 27245
:
114521
|
114750
|
114958