Search code examples
mysqlmariadbdeadlockdatabase-deadlocksgalera

Outdated deadlock info in 'show engine innodb status'


I'm running a MariaDB Galera cluster with 3 nodes based on MariaDB 10.1.32. Currently im getting quite a lot of "Deadlock found" messages like this in my syslog:

2018-05-04  9:21:33 140130671872768 [ERROR] mysqld: Deadlock found when trying to get lock; try restarting transaction

In order to find the cause of the deadlocks i run "show engine innodb status" but the section "LATEST DETECTED DEADLOCK" only contains outdated info (according to the timestamp):

------------------------
LATEST DETECTED DEADLOCK
------------------------
2018-04-28 21:21:08 7f71a9450b00
*** (1) TRANSACTION:
[...]

Why are there deadlocks reported in the log but they don't show up in output of "show engine innodb status"?


Solution

  • The short answer is that Galera can throw deadlock errors that are not InnoDB deadlocks.

    The only thing you'll see in SHOW ENGINE INNODB STATUS; are InnoDB deadlocks where multiple transactions on the same server tried to obtain incompatible locks. These never occur at transaction commit -- they are always earier than this, being the result of the pessimistic locking built in to InnoDB. They only appear on the server where they occurred.

    Galera will throw a deadlock when transactions across multiple servers are trying to commit conflicting results, and these transactions collide. These occur at transaction commit, or at implicit commit if you're in autocommit mode, as a result of Galera's optimistic locking. These are conflicts between writes to different masters.

    http://galeracluster.com/documentation-webpages/dealingwithmultimasterconflicts.html