Bugzilla – Attachment 62459 Details for
Bug 18364
LOCK and UNLOCK are not transaction-safe
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18364: [Follow-up] Also add an environment variable to prevent locking
Bug-18364-Follow-up-Also-add-an-environment-variab.patch (text/plain), 2.50 KB, created by
Marcel de Rooy
on 2017-04-20 11:28:01 UTC
(
hide
)
Description:
Bug 18364: [Follow-up] Also add an environment variable to prevent locking
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-04-20 11:28:01 UTC
Size:
2.50 KB
patch
obsolete
>From 8902254e28469a716c02b7b5bcaba686dbcf42fa Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 20 Apr 2017 12:52:47 +0200 >Subject: [PATCH] Bug 18364: [Follow-up] Also add an environment variable to > prevent locking >Content-Type: text/plain; charset=utf-8 > >The test in SendCirculationAlert is extended by adding an env var >called KOHA_NO_TABLE_LOCKS. If this var is set to a true value, >the table locking is skipped too. > >This is useful when running a test without prove. The variable could be >set in a shell profile. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Circulation.pm | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 9d613d5..67b3a4c 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -3364,7 +3364,7 @@ sub SendCirculationAlert { > # LOCK TABLES is not transaction-safe and implicitly commits any active transaction before attempting to lock the tables. > # If the LOCK/UNLOCK statements are executed from tests, the current transaction will be committed. > # To avoid that we need to guess if this code is execute from tests or not (yes it is a bit hacky) >- my $called_from_tests = exists $ENV{_} and $ENV{_} =~ m|prove|; >+ my $do_not_lock = ( exists $ENV{_} && $ENV{_} =~ m|prove| ) || $ENV{KOHA_NO_TABLE_LOCKS}; > > for my $mtt (@transports) { > my $letter = C4::Letters::GetPreparedLetter ( >@@ -3383,17 +3383,17 @@ sub SendCirculationAlert { > ) or next; > > $schema->storage->txn_begin; >- C4::Context->dbh->do(q|LOCK TABLE message_queue READ|) unless $called_from_tests; >- C4::Context->dbh->do(q|LOCK TABLE message_queue WRITE|) unless $called_from_tests; >+ C4::Context->dbh->do(q|LOCK TABLE message_queue READ|) unless $do_not_lock; >+ C4::Context->dbh->do(q|LOCK TABLE message_queue WRITE|) unless $do_not_lock; > my $message = C4::Message->find_last_message($borrower, $type, $mtt); > unless ( $message ) { >- C4::Context->dbh->do(q|UNLOCK TABLES|) unless $called_from_tests; >+ C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock; > C4::Message->enqueue($letter, $borrower, $mtt); > } else { > $message->append($letter); > $message->update; > } >- C4::Context->dbh->do(q|UNLOCK TABLES|) unless $called_from_tests; >+ C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock; > $schema->storage->txn_commit; > } > >-- >2.1.4
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 18364
:
61758
|
62074
|
62458
| 62459