[Koha-bugs] [Bug 15854] Race condition for sending renewal/check-in notices

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Mar 3 20:23:46 CET 2017


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

Marc Véron <veron at veron.ch> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #60057|0                           |1
        is obsolete|                            |

--- Comment #6 from Marc Véron <veron at veron.ch> ---
Created attachment 60813
  -->
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=60813&action=edit
Bug 15854: Simplify the code to limit race conditions

There is an obvious race condition when CHECKIN and RENEWAL are
generated from circulation.pl calling svc/renew or svc/checkin in AJAX.

The 2 first queries will try to get the id of the last message
(find_last_message) and if it does not exist, they will insert it.
Theorically that could be lead to have several "digest" messages for a
given patron.
I did not recreate more than 2 messages, from the third one at least one
of the two firsts existed in the DB already.

This patch just simplifies the code to make the SELECT and INSERT or
UPDATE closer and limit the race condition possibilities.

Test plan:
0. Set RenewalSendNotice and circ rules to have a lot of renewals available
1. Use batch checkouts (or one by one) to check out several items to a
patron
2. Empty message_queue (at least of this patron)
3. Renew them all at once ("select all" link, "renew or check in"
button)
4. Check the message_queue
Without this patch you have lot of chances to faced a race condition and
get at least 2 messages for the same patron. This is not expected, we
expect 1 digest with all the messages.
With this patch apply you have lot of chances not to face it, but it's
not 100% safe as we do not use a mechanism to lock the table at the DBMS
level.

Tested both patches together, works as expected.
Signed-off-by: Marc Véron <veron at veron.ch>

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


More information about the Koha-bugs mailing list