MySQL服务器经常丢失但应用程序运行完美

Environment is Godaddy, shared hosting using Linux, Mysql, php 7.2, laravel 5.7.

I have not touched framework code. I simply used Laravel documentation to run artisan commands and log information.

I created a cronjob that runs every 5 min to run scheduler for email jobs that periodically sends mails based on registration, birthdays and other activities and backing-up DB at 4 times a day. I get the errors in my log file described below:

production.ERROR: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away (SQL: select * from jobs where queue = default and ((reserved_at is null and available_at <= timestamp) or (reserved_at <= timestamp)) order by id asc limit 1 for update). Timestamps are different but query is same.

production.ERROR: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) {"exception":"[object] (PDOException(code: 2002):SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

production.ERROR: Call to a member function beginTransaction() on null {"exception":"[object] Symfony\Component\Debug\Exception \FatalThrowableError (code: 0):

None of the scheduled tasks were either aborted or not executed for any error. All these scheduled tasks get executed perfectly. Ex: When I request an email send, it gets posted to same jobs table, and the same entries are vanished in a flash and I get the mail delivered at the destination. Strangely, I get this error frequently in between, when no activity or interaction with the application is done (meaning none is interacting with the application). I do not find any issue with the query as I have executed the same query in phpMyAdmin, in my local console or in MySQL workbench. This is the default framework query.

protected $commands = [
    //
    Commands\SendBirthdayEmail::class,
    Commands\SendReminderEmail::class,
    Commands\ManageLogs::class,
    Commands\BackupDb::class,
];

/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{

   $schedule->command('manage:logfiles')->weekly()->sundays()->at('01:15');
   $schedule->command('backup:stdb')->dailyAt('01:20');
   $schedule->command('backup:stdb')->dailyAt('05:20');

   $schedule->command('email:birthday')->dailyAt('05:55');
   $schedule->command('email:reminder')->dailyAt('06:00');

   $schedule->command('backup:stdb')->dailyAt('13:45');
   $schedule->command('backup:stdb')->dailyAt('19:20');
   $schedule->command('backup:stdb')->dailyAt('21:20');
   $schedule->command('queue:work --tries=3')->everyFiveMinutes();
}

Even after these entries (supposedly with lost connection state), the next task gets executed perfectly as desired.

I have searched all over but could not find an issue with jobs table as well as the reason for these log entries. Always the same jobs table is shown as the problematic query.

donglian2106
donglian2106 解决:看起来像。罪魁祸首似乎是最后一个调度命令队列:work--tries=3。在我注释掉之后,错误没有出现在过去的10个小时内。其他一切都运转得很好。
一年多之前 回复
dongsu4345
dongsu4345 我在CPanel或WHM中思考你可以找到日志。通常它位于/var/log/MySQL/error.log中
一年多之前 回复
doudengshen5591
doudengshen5591 我不确定我的回答是否正确。我只检查了状态选项卡,在该选项卡下收集了所有红色标记的数字以提高性能。因为查询号码很慢。我想知道一些数字,是否只是我的部分MySQL(它是共享主机)或它反映了整群用户在一起作为一些变量像杀死进程等,从来没有用过我的包。
一年多之前 回复
dongxiong1935
dongxiong1935 MySQL错误日志在失败期间会出现什么情况?
一年多之前 回复
dongrong9938
dongrong9938 我还检查了分配给我们的8GB的默认交换空间,其中占用了1GB和6.8GB。这个问题超出了我的范围!
一年多之前 回复
dongqiao1964
dongqiao1964 谢谢你,你可能是对的但是当我检查了服务器内存时,它从未超过68-70%的分配。其次,运行应用程序(不与它交互)不应该消耗太多资源,除了每5分钟运行一次的cronjob。检测到这些错误时,我没有看到CPU使用率或内存出现任何峰值。我仍然会研究这个建议。
一年多之前 回复
dsndm82062
dsndm82062 我相信服务器内存在cron进程中耗尽或者可能由于某些其他原因而且mysql无法运行自己的进程。例如,即使yorus是godaddy上的共享托管,也可以看作是参考证明。
一年多之前 回复
dtest84004
dtest84004 我认为它与超时或查询大小或数据包大小无关,因为表是空的(没有待处理的作业)。我还检查了MySQLPROCESSLIST只有两个/三个存在
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐