Bugzilla – Attachment 114184 Details for
Bug 26457
DB DeadLock when renewing checkout items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26457: Throw exception if update of issues table fails
Bug-26457-Throw-exception-if-update-of-issues-tabl.patch (text/plain), 2.79 KB, created by
Nick Clemens (kidclamp)
on 2020-12-04 12:07:09 UTC
(
hide
)
Description:
Bug 26457: Throw exception if update of issues table fails
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2020-12-04 12:07:09 UTC
Size:
2.79 KB
patch
obsolete
>From 004af228443af9a407d51851f2552aa21dcec850 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 4 Dec 2020 12:03:52 +0000 >Subject: [PATCH] Bug 26457: Throw exception if update of issues table fails > >While this won't prevent the deadlock, it should catch the case where >a deadlock causes the DB update to fail and provide feedback to the user >and rollback the transaction > >I don't know how to trigger the deadlock, I can only confirm that we see it, and >that this should catch it. > >To test: >1 - Apply patches >2 - Confirm that 'Renew all' feature continues to work as expected >--- > C4/Circulation.pm | 8 +++++++- > svc/renew | 13 +++++++++++-- > 2 files changed, 18 insertions(+), 3 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 602bc54f6b..e067d306b7 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -59,6 +59,7 @@ use Koha::Charges::Fees; > use Koha::Util::SystemPreferences; > use Koha::Checkouts::ReturnClaims; > use Koha::SearchEngine::Indexer; >+use Koha::Exceptions::Checkout; > use Carp; > use List::MoreUtils qw( uniq any ); > use Scalar::Util qw( looks_like_number ); >@@ -3084,7 +3085,12 @@ sub AddRenewal { > AND itemnumber=?" > ); > >- $sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $unseen_renewals, $lastreneweddate, $borrowernumber, $itemnumber ); >+ my $success =$sth->execute( $datedue->strftime('%Y-%m-%d %H:%M'), $renews, $unseen_renewals, $lastreneweddate, $borrowernumber, $itemnumber ); >+ unless ( $success ){ >+ Koha::Exceptions::Checkout::RenewalFailed->throw( >+ error => 'unable to update issue ' . $issue->issue_id >+ ); >+ } > > # Update the renewal count on the item, and tell zebra to reindex > $renews = ( $item_object->renewals || 0 ) + 1; >diff --git a/svc/renew b/svc/renew >index e7792ddd60..9a890d77a7 100755 >--- a/svc/renew >+++ b/svc/renew >@@ -21,6 +21,7 @@ use Modern::Perl; > > use CGI; > use JSON qw(to_json); >+use Try::Tiny; > > use C4::Circulation; > use C4::Context; >@@ -67,8 +68,16 @@ if ( $data->{error} && $data->{error} eq 'on_reserve' && C4::Context->preference > } > > if ( $data->{renew_okay} ) { >- $date_due = AddRenewal( $borrowernumber, $itemnumber, $branchcode, $date_due, undef, undef, $seen ); >- $data->{date_due} = output_pref( { dt => $date_due, as_due_date => 1 } ); >+ try{ >+ $date_due = AddRenewal( $borrowernumber, $itemnumber, $branchcode, $date_due, undef, undef, $seen ); >+ $data->{date_due} = output_pref( { dt => $date_due, as_due_date => 1 } ); >+ } catch { >+ if ( ref($_) eq 'Koha::Exceptions::Checkout::RenewalFailed' ) { >+ $data->{error} = 'renewal_failed'; >+ } else { >+ $_->rethrow; >+ } >+ } > } > > print to_json($data); >-- >2.11.0
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 26457
:
114184
|
114185
|
114186
|
114187
|
114190
|
114669
|
114697
|
117227
|
117228
|
117371
|
117372
|
117373
|
117876
|
118647