drqvr26084 2019-02-14 00:31 采纳率: 100%
浏览 88

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料
    • ¥15 使用R语言marginaleffects包进行边际效应图绘制
    • ¥20 usb设备兼容性问题
    • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
    • ¥15 安装svn网络有问题怎么办
    • ¥15 vue2登录调用后端接口如何实现