[Koha-bugs] [Bug 33972] Possible deadlock in C4::ImportBatch::SetimportBatchStatus from BatchCommitRecords

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Jun 15 16:27:14 CEST 2023


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33972

--- Comment #4 from Marcel de Rooy <m.de.rooy at rijksmuseum.nl> ---
(In reply to Nick Clemens from comment #0)
> In BatchCommitRecords we currently
> 
> Start a transaction
> ...
> SetImportBatchStatus($batch_id, 'importing');
> ...
> SetImportBatchStatus($batch_id, 'finished');
> ...
> Finish the transaction
> 
> 
> In certain settings the second call fails as it is waiting for the first to
> commit it seems:
> [Fri Jun  9 09:06:29 2023] 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
> 
> Setting the status twice inside the transaction doesn't make sense - the DB
> will never show the 'importing' status - as it will either be rolled back
> when the transaction fails, or set to 'finished' when it completes

Normally, you should be able to update the same record within the same
transaction. And only another transaction trying to get/update this same record
in import_batches should be locked.
So, are you sure that there was no second process involved?

The other thing, though, is that SetImportBatchStatus asks for another db
handle via Context/Koha::Database. Since you have a connection, you would not
expect a problem. But is it possible that somehting there somehow goes wrong?

Would it be an idea to move the second SetImportBatchStatus call at the end
also after the transaction?

Hard to verify if we dont know the exact cause and cannot reproduce..

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list