• mysql 死锁问题


    关闭自动提交:
    
    autocommit=0;
    
    SESSION A:
    
    Database changed
    mysql> select * from ProductQuota;
    +-----------+-------------+
    | productSn | frozenQuota |
    +-----------+-------------+
    |       200 |         100 |
    +-----------+-------------+
    1 row in set (0.00 sec)
    
    mysql> select * from test;
    +----+------+
    | id | name |
    +----+------+
    |  1 | a    |
    +----+------+
    1 row in set (0.00 sec)
    
    mysql> update ProductQuota  set frozenQuota='200' where productSn=200;
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> update test set name='b' where id=1;
    ---hang
    
    
    
    SESSION B:
    
    
    mysql>  update test set name='b' where id=1;
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> update ProductQuota  set frozenQuota='200' where productSn=200;
    ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction

  • 相关阅读:
    js开发笔记
    安全相关开发笔记
    常用.NET库使用总结
    Windows使用总结
    .NET Web开发笔记
    Unity插件使用总结
    WinForm开发笔记
    C#开发笔记
    iTunes使用总结
    Mac使用总结
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6200189.html
Copyright © 2020-2023  润新知