场景
在Flask项目中使用peewee扩展playhouse中的PooledMySQLDatabase 连接MySQL数据库 =>
from playhouse.pool import PooledMySQLDatabase
使用celery+rabbitmq做定时任务,每15分钟将数据从MySQL同步到MongoDB。启动服务、rabbitmq、celery定时任务,使用flower监控。数分钟后,任务执行失败,错误信息 Error 2006:MySQL server has gone away;Error 2013:Lost connection to MySQL server during query
参数设置
MySQL Server:wait_timeout(以前版本的Connection Lifetime)= 28800(8个小时,默认配置),
peewee(PooledMySQLDatabase):stale_timeout=600, max_connections=32(其余参数使用默认值)
wait_timeout官方定义如下:
The number of seconds the server waits for activity on a noninteractive connection before closing it.
On thread startup, the session wait_t