我试图锁定时发现了死锁;尝试重新启动InnoDB表上的事务错误.这是查询:
UPDATE views SET visit_cnt = visit_cnt + 1 WHERE visit_day = DATE(NOW()) AND article_id = '4838'
此查询还通过ON UPDATE触发器触发此操作:
UPDATE articles SET views = views + 1 WHERE id = NEW.article.id
以下是我尝试修复它的方法:
$attempts_left = 5; do { MysqL_query ($query); // if we found a deadlock,we will try this query 4 more times if (MysqL_errno () == 1213) { // 1213 - deadlock error $deadlocked = true; $attempts_left --; } else{ $deadlocked = false; } } while($deadlocked && $attempts_left > 0);
这是关于处理
InnoDB deadlocks的好文档.
原文链接:https://www.f2er.com/php/134296.html