惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
WordPress大学
WordPress大学
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
S
Secure Thoughts
博客园 - 【当耐特】
Know Your Adversary
Know Your Adversary
NISL@THU
NISL@THU
博客园 - 司徒正美
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
P
Privacy & Cybersecurity Law Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
B
Blog
The GitHub Blog
The GitHub Blog
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
Martin Fowler
Martin Fowler
博客园 - 叶小钗
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Tenable Blog
S
Securelist
博客园 - 三生石上(FineUI控件)
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Security Blog
Microsoft Security Blog
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
T
Threat Research - Cisco Blogs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
Cloudbric
Cloudbric
The Cloudflare Blog
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - Blog
Microsoft Azure Blog
Microsoft Azure Blog
H
Hacker News: Front Page
腾讯CDC
L
Lohrmann on Cybersecurity
C
CERT Recently Published Vulnerability Notes
V2EX - 技术
V2EX - 技术
GbyAI
GbyAI
TaoSecurity Blog
TaoSecurity Blog
I
Intezer
The Last Watchdog
The Last Watchdog
G
GRAHAM CLULEY
Google Online Security Blog
Google Online Security Blog
T
The Blog of Author Tim Ferriss

博客园 - Tinywan

响应错误: Indirect modification of overloaded element of app\model\StudentCacheModel has no effect - Tinywan Ubuntu 22.04 编译安装 PHP 7.4.33 报错:make: *** [Makefile:749: ext/openssl/openssl.lo] Error 1 how to set mpdf HTML contains invalid UTF-8 character(s) 和 CPU 100% Redis Docekr WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition Nginx添加第三方模块,出现“is not binary compatible in”错误的解决方案 Docker 数据库连接见解异常 SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again Java系列 | 如何讲自己的JAR包上传至阿里云maven私有仓库【云效制品仓库】 Redis系列 | 分类树查询功能如何从2s优化到0.1s Docker系列 | docker endpoint for “default” not found Node系列 | Node版本管理工具 fnm Java系列 | IntelliJ IDEA 如何导入和使用一个Jar包 Chrome扩展插件:Console Importer(控制台导入器) PHP系列 | mPdf字体库异常 Cannot find TTF TrueType font file "Eeyek.ttf" in configured font directories PHP系列 | PHP中的stdClass是什么? 网络安全 | 记录一次acme.sh更新证书 Error add txt for domain:_acme-challenge.tinywan.com 大数据系列 | 阿里云datav数据可视化(使用json文件生成可视化动态图标) Docker系列 | SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again768 Java系列 | Linux系统中运行JMeter脚本 PHP系列 | TP6使用表达式设置数据 Db::raw('end_time')
解决mysql死锁问题 SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction
Tinywan · 2023-12-04 · via 博客园 - Tinywan

钉钉机器人报警了

SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction

 在PHP调试时 提交事务触发异常后没有执行回滚导致mysql死锁,以致后续请求更新不了数据

问题原因

在mysql中事务a执行修改数据,比如: update table set a=1 where id=1;此时事务并未进行提交也没有回滚,然后事务B开始运行,修改同一条数据: update table set a=2 where id=1;

问题出现环境

1、在同一事务内先后对同一条数据进行插入和更新操作;

2、多台服务器操作同一数据库;

3、瞬时出现高并发现象;

4、语句中没有执行commit,也没有rollback就return退出了

比如参数检查不通过,直接return错误信息,导致回滚不能执行

如以下代码先执行了更新操作,后面出错又直接返回,导致没有执行rollback,对于这种操作return前一点要回滚,或者抛出异常统一扑捉后返回错误信息

$this->startTrans();
try {
   $user = new User();
   $user->where('id',$userId)->update(['realname'=>$parentName]);
   $existId = $this->where('class_id',$classId)->where('student_number',$number)->find();
   if ($existId) {
      return ['data' => '', 'code' => 300, 'msg' => '学号重复'];
   }
   $this->commit();
} catch (Throwable $e) {
   $this->rollback();
   return ['data' => '', 'code' => 20102, 'msg' => $e->getMessage()];
}

更多:https://blog.51cto.com/u_12390904/6254246