Bug 35220

Summary: Merging patrons can cause lock timeouts
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: PatronsAssignee: Bugs List <koha-bugs>
Status: NEW --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: bowens, gmcharlt, kyle, rcoert
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
Circulation function:

Description Nick Clemens (kidclamp) 2023-11-01 18:49:42 UTC
The code to merge patrons uses a transaction to update all of the related patron tables.

On systems with a long history (i.e. a big statistics table) this operation can take 30 seconds or more, which begins to cause issues writing to the tables.

We need to find a way to speed this up, or to defer the merging of patrons.
Comment 1 Nick Clemens (kidclamp) 2024-04-11 13:58:27 UTC
I was able to recreate this by adding a Sleep 100; after the update statement in merge with, and reducing the table updates ot only Statistics - then checkouts failed while waiting for the lock

It seems the best idea here is to defer patron merges and handle them via a nightly cronjob