From 402360313d669f18e6ff864f9e52a424c9389f4e Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 9 Jun 2023 13:16:32 +0000 Subject: [PATCH] Bug 33972: Set importing status to batch outside of transaction Content-Type: text/plain; charset=utf-8 This patch moves the setting of the 'importing' status for the batch outside fo the transaction. This prevents a scenario seen on some setups where a deadlock is created: background_jobs_worker.pl: C4::ImportBatch::SetImportBatchStatus(): DBI Exception: DBD::mysql::db do failed: Lock wait timeout exceeded; try restarting transaction at /usr/share/koha/lib/C4/ImportBatch.pm line 717 To test: 1 - Apply patch 2 - Stage and import some files 3 - Confirm the imports successfully complete Signed-off-by: Marcel de Rooy --- C4/ImportBatch.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm index cbcdeb5936..2a6db4f90c 100644 --- a/C4/ImportBatch.pm +++ b/C4/ImportBatch.pm @@ -536,6 +536,8 @@ sub BatchCommitRecords { $progress_interval = 0 unless $progress_interval && $progress_interval =~ /^\d+$/; $progress_interval = 0 unless ref($progress_callback) eq 'CODE'; + SetImportBatchStatus($batch_id, 'importing'); + my $schema = Koha::Database->schema; $schema->txn_begin; # NOTE: Moved this transaction to the front of the routine. Note that inside the while loop below @@ -549,7 +551,6 @@ sub BatchCommitRecords { my $num_items_errored = 0; my $num_ignored = 0; # commit (i.e., save, all records in the batch) - SetImportBatchStatus($batch_id, 'importing'); my $overlay_action = GetImportBatchOverlayAction($batch_id); my $nomatch_action = GetImportBatchNoMatchAction($batch_id); my $item_action = GetImportBatchItemAction($batch_id); -- 2.30.2