Mysql innodb常见死锁总结

InnoDB锁

InnoDB事物

死锁举例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
-- 第一种
start transaction ;

# 4
UPDATE tx_order
SET order_status = '12',
  after_sale_status = '0',
  promotion_total_amount = '0.00',
  payable_amount = '2000.00',
  refunded_amount = '2000.00',
  paid_amount = '2000.00',
  last_update_date = now( )
WHERE
  id = 784339
;

# 1
update tx_order.tx_order set last_update_date=now() where id = 784330;


COMMIT;




start transaction ;
# 2
UPDATE tx_order
SET order_status = '12',
  after_sale_status = '0',
  promotion_total_amount = '0.00',
  payable_amount = '2000.00',
  refunded_amount = '2000.00',
  paid_amount = '2000.00',
  last_update_date = now( )
WHERE
  id = 784339
;
# 3
update tx_order.tx_order set last_update_date=now() where id = 784330;


COMMIT;

reference