下列的例子演示当锁定请求可能会导致死锁之时一个错误会如何发生。例子中包括两个客户端A和B。首先客户端A创建一个包含一个行的表,然后开始一个事务。在这个事务内,A通过在共享模式选择行获得对行的S 锁定:mysql> CREATE TABLE t (i INT) ENGINE = InnoDB;Query OK, 0 rows affected (1.07 sec) mysql> INSERT INTO t (i) VALUES(1);Query OK, 1 row affected (0.09 sec) mysql> START TRANSACTION;Query OK, 0 rows affected (0.00 sec) mysql> SELECT * FROM t WHERE i = 1 LOCK IN SHARE MODE;+------+| i |+------+| 1 |+------+1 row in set (0.10 sec)接着,客户端B开始一个事务并尝试从该表删除行:mysql> START TRANSACTION;Query OK, 0 rows affected (0.00 sec) mysql> DELETE FROM t WHERE i = 1;删除操作要求一个X 锁定。因为这个锁定不兼容客户端A持有的S锁定,所以X 锁定不被允许,所以请求进入对行及客户端阻挡的锁定请求队列。最后,客户端A也试图从表中删除该行:mysql> DELETE FROM t WHERE i = 1;ERROR 1213 (40001): Deadlock found when trying to get lock;try restarting transaction