当前位置:   article > 正文

Lock wait timeout exceeded; try restarting transaction mysql报错_mysql record lock timeout c#

mysql record lock timeout c#

问题描述:

提示:最近项目中频繁出现 Lock wait timeout exceeded; try restarting transaction这个错误,把我们弄得痛苦不堪啊,为了解决问题,上网上找好多资料。

问题复现

终于把问题复现了。具体操作步骤如下(我使用的mysql工具是 navicat):

第一步:开启sql命令页面

在这里插入图片描述

第二步:输入start transaction;开启一个事务

第三步:输入update语句不要提交

UPDATE TABLENAME set time=null where id=29163;(切记不要 提交(commit;))

第四步:书写测试类

运行程序

public class StTest implements Runnable{
   
    private  static ApplicationContext applicationContext=null;
    private static AtomicInteger a=new AtomicInteger(0);
    static {
   
         applicationContext=new ClassPathXmlApplicationContext("classpath:application.xml");
    }
    public static void main(String[] args) throws Exception {
   
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        for (int i = 0; i <10 ; i++) {
   
            executorService.execute(new aaaa());
        }
        if(!executorService.isTerminated()){
   
            executorService.shutdown();
        }
    }
 
    @Override
    public void run()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/729232
推荐阅读
相关标签
  

闽ICP备14008679号