Bugzilla – Attachment 150369 Details for
Bug 32990
Possible deadlock in C4::ImportBatch::_update_batch_record_counts
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32990: Prevent deadlock in _update_batch_record_counts
Bug-32990-Prevent-deadlock-in-updatebatchrecordcou.patch (text/plain), 2.60 KB, created by
Nick Clemens (kidclamp)
on 2023-04-28 13:05:37 UTC
(
hide
)
Description:
Bug 32990: Prevent deadlock in _update_batch_record_counts
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-04-28 13:05:37 UTC
Size:
2.60 KB
patch
obsolete
>From 102ead5e8bb80ec7267c92b035249f8e9a199864 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 17 Feb 2023 08:33:41 +0000 >Subject: [PATCH] Bug 32990: Prevent deadlock in _update_batch_record_counts > >Resolves: >C4::ImportBatch::_update_batch_record_counts(): DBI Exception: DBD::mysql::st execute failed: Deadlock found when trying to get lock; try restarting transaction at /usr/share/koha/C4/ImportBatch.pm line 392 > >See also bug 32558. > >Test plan: >If you apply 32558 first, run multiple processes that stage a marc import. >Without this patch, you can trigger the deadlock. >With this patch, it works. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/ImportBatch.pm | 23 +++++++++++++---------- > 1 file changed, 13 insertions(+), 10 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index f9e248b630..8f5cf00a1c 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -1724,21 +1724,24 @@ sub _update_batch_record_counts { > my ($batch_id) = @_; > > my $dbh = C4::Context->dbh; >- my $sth = $dbh->prepare_cached("UPDATE import_batches SET >- num_records = ( >+ my ( $num_records ) = $dbh->selectrow_array(q| > SELECT COUNT(*) > FROM import_records >- WHERE import_batch_id = import_batches.import_batch_id), >- num_items = ( >+ WHERE import_batch_id = ? >+ |, undef, $batch_id ); >+ my ( $num_items ) = $dbh->selectrow_array(q| > SELECT COUNT(*) > FROM import_records > JOIN import_items USING (import_record_id) >- WHERE import_batch_id = import_batches.import_batch_id >- AND record_type = 'biblio') >- WHERE import_batch_id = ?"); >- $sth->bind_param(1, $batch_id); >- $sth->execute(); >- $sth->finish(); >+ WHERE import_batch_id = ? AND record_type = 'biblio' >+ |, undef, $batch_id ); >+ $dbh->do( >+ "UPDATE import_batches SET num_records=?, num_items=? WHERE import_batch_id=?", >+ undef, >+ $num_records, >+ $num_items, >+ $batch_id, >+ ); > } > > sub _get_commit_action { >-- >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 32990
:
146752
|
147785
| 150369