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.
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