Handling innoDB deadlock
问题 I've been getting a Deadlock found when trying to get lock; try restarting transaction error on my InnoDB tables. Here is the query: UPDATE views SET visit_cnt = visit_cnt + 1 WHERE visit_day = DATE(NOW()) AND article_id = '4838' This query also triggers this via ON UPDATE trigger: UPDATE articles SET views = views + 1 WHERE id = NEW.article.id Here is how I tried to fixed it: $attempts_left = 5; do { mysql_query ($query); // if we found a deadlock, we will try this query 4 more times if