]> git.koha-community.org Git - koha.git/commit
Bug 15854: Use a READ and WRITE LOCK on message_queue
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 9 Feb 2017 11:44:38 +0000 (12:44 +0100)
committerBrendan A Gallagher <brendan@bywatersolutions.com>
Thu, 23 Mar 2017 00:47:28 +0000 (00:47 +0000)
commitbe156d9ad9e5bcfadab34d44f90e04fd61e256ad
tree7ea003eecc1371ed1bdaf97ab55ea35297e08c3c
parent607b14516a955c9989e4764c69527edbc1f36ba0
Bug 15854: Use a READ and WRITE LOCK on message_queue

To make sure we will not never get a race conditions for these kinds of
notices, we need to add a LOCK on the message_queue table.

This does not smell the best way to do that, but I faced deadlock issues
when I tried to use "UPDATE FOR"

https://dev.mysql.com/doc/refman/5.7/en/innodb-locking-reads.html
https://dev.mysql.com/doc/refman/5.7/en/lock-tables.html
https://dev.mysql.com/doc/refman/5.7/en/commit.html

To test this patch, or another solution, you need to apply manually this
change:

         my $message = C4::Message->find_last_message($borrower, $type, $mtt);
         unless ( $message ) {
+            sleep(1);
             C4::Message->enqueue($letter, $borrower, $mtt);
         } else {

And repeat the test plan from first patch.
Do not forget to truncate the message_queue table.

Followed test plans, works as expected.
Signed-off-by: Marc VĂ©ron <veron@veron.ch>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
C4/Circulation.pm