Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

如果在产生Mysql Server Has Gone Away的时候想重新连接怎么办?@qiang.xue

$
0
0
首先感谢qiang给我们共享了一个这么受用的web框架。
在使用yii的过程中,我遇到了一个问题,大致概述如下:
$user_list = fetch_user_from_db();
foreach($user_list as $user)
{
    send_mail_to_user($user->id);
    update_db_user_mail_status($user->id);
}

mysql wait_timeout配置10秒;
在这个crontab执行的过程中,由于send_mail_to_user调用的外部服务,它返回时间在极少数情况下会有超过10秒的情况。最终导致超过mysql wait_timeout的设置。于是在db层增加一个gone away重连的机制(CDbCommand里面的函数execute和queryInternal中增加了判断),加上以后通过CDbcommand进行的操作成功进行了重连,但是通过activerecord进行的操作还是无效。由于对框架的理解还不是特别深入,所以不知道把这个机制加到什么地方比较好。 :lol:

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>