Kristian Nielsen <knielsen@xxxxxxxxxxxxxxx> writes:
The patch makes later transactions wait for earlier transactions to
commit
before committing themselves.
Hm, I now realise a problem with this approach :-/
The problem is with MyISAM tables, or other tables that use
table-level
locking instead of row-level locking.
If transactions T1 and T2 both update the same table mytable, then it
can
happen that T2 runs first and gets a table lock on table mytable. T1
then has
to wait for T2 to commit, after which the table lock is released. But
T2 will
never commit, it will wait for T1 to commit first with my patch. Thus
we have
a deadlock.
One way to fix this could be to extend your algorithm for detecting
conflicts
between different transactions. If some table T uses table-level
locking, then
put into the hash just the table name, without any primary key
values. Then
any two such transactions will be considered conflicting, and we
avoid the
deadlock. No loss of parallelism should occur, as two updates to the
same
MyISAM table can anyway not run in parallel.