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
wherequeue
= default and ((reserved_at
is null andavailable_at
<= timestamp) or (reserved_at
<= timestamp)) order byid
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.