如下程序,为什么会出现死锁?

mysql> show create table test;
+-------+-----------------------------------------
| Table | Create Table
+-------+-----------------------------------------
| test  | CREATE TABLE `test` (
  `id` bigint(20) NOT NULL auto_increment,
  `master` bigint(20) NOT NULL,
  `markID` int(11) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `master` (`master`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 |
+-------+-----------------------------------------

mysql> select * from test;
+----+--------+--------+
| id | master | markID |
+----+--------+--------+
|  1 |      1 |    100 |
|  2 |      2 |    200 |
+----+--------+--------+
2 rows in set (0.00 sec)

procedure1:
begin
update test set markID = 200 where id =2;
update test set markID = 100 where id = 1;
end

procedure2:
begin
update test set markID = 100 where id = 1;
update test set markID = 200 where id =2;
end

两个存储过程同时调用,请问为什么会造成死锁啊?

你可能感兴趣的:(如下程序,为什么会出现死锁?)