Sorry, I missed this part of your message:
Threads may also get stuck in a transaction, but it
_should_ be possible
to get out of it by running a 'ROLLBACK' at the start of each run to
cancel anything that may have gotten stuck. (Warning: untested theory!)
Further, nothing has to lock; the first transaction to commit wins, and
any conflicting transactions will get an error when they try to commit,
or just vanish into the ether if the thread dies.
I think I should read up on this again. BTW, BEGIN will commit any active
transactions.
* If another
thread tries to get the lock but times out, it kills the
offending DB thread
Which is now doing something unrelated serving a different web request...
Good point. The script could check the HEAP table when it first acquires the
connection, but it may be better to do it your way.
-- Tim Starling <tstarlingphysicsunimelbeduau>