When using script to import records misc/migration_tools/bulkmarcimport.pl, I get the error : .DBD::mysql::db begin_work failed: Already in a transaction at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1588, <GEN45> line 1. I thinks it is because of transaction in the script : $dbh->{AutoCommit} = 0; And C4::Biblio::AddBiblio launches a transation : $schema->txn_do(sub { Records are imported well but its a scary error :/
Looks like it is since Bug 26518
Created attachment 114521 [details] [review] 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)
Without the patch I'm getting «Already in a transaction» even with a (supposedly) valid MARCXML file with 120 records. I just exported the first 120 records of the sample data in XML. With the patch, with valid or invalid data, it's just importing one record: kohadev-koha@kohadevbox:/kohadevbox/koha$ misc/migration_tools/bulkmarcimport.pl -commit 10 -file 120-records.xml . 1 MARC records done in 0.0640840530395508 seconds kohadev-koha@kohadevbox:/kohadevbox/koha$ misc/migration_tools/bulkmarcimport.pl -commit 10 -file 120-records-one-invalid.xml . 1 MARC records done in 0.0556449890136719 seconds Maybe I'm missing a param from bulkmarcimport.pl? (-b doesn't help)
For me its ok, works as expected
Created attachment 114750 [details] [review] 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) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
@Fridolin how did you use bulkmarcimport.pl ? And how did you get the records? So I can test with then to check if my records were wrong.
Created attachment 114958 [details] [review] 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: 1 - Export more than 100 records 2 - Use bulkmarcimport (with -commit=10) to import them perl misc/migration_tools/bulkmarcimport.pl -b -file testbmi.xml -v -m=MARCXML --commit=10 3 - Modify a record to make the import fail (for instance having a too long lccn) 4 - Use bulkmarcimport (with -commit=10) to import them perl misc/migration_tools/bulkmarcimport.pl -b -file testbmi.xml -v -m=MARCXML --commit=10 5 - Notice that the import stops but that the imported record are imported (apart from the last batch of 10) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Pushed to master for 21.05, thanks to everybody involved!
Pushed to 20.11.x for 20.11.02
Pushed to 20.05.x for 20.05.08
Backported: Pushed to 19.11.x branch for 19.11.14