Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQL server has gone away from cron scheduler #178

Open
Xymanek opened this issue Jul 7, 2017 · 1 comment · May be fixed by #237
Open

MySQL server has gone away from cron scheduler #178

Xymanek opened this issue Jul 7, 2017 · 1 comment · May be fixed by #237

Comments

@Xymanek
Copy link

Xymanek commented Jul 7, 2017

I made a cron command using ScheduleEveryOtherMinute trait, however the scheduler crashes every second time it tries to create the job with Warning: PDOStatement::execute(): MySQL server has gone away exception.

A possible fix for this would running something like this every loop iteration:

if ($em->getConnection()->ping() === false) {
    $em->getConnection()->close();
    $em->getConnection()->connect();
}

If I recall correctly, the EntityManager doesn't get closed if you disconnect/connect the underlying connection manually so the rest of code should work without any changes.

If every loop iteration seems excessive then perhaps an option like --conn-ping-interval which will allow to define a custom interval to run the code above.

Thoughts (I can make a PR)?

@schmittjoh
Copy link
Owner

Seems like a good idea to add.

mauroaltamura pushed a commit to mauroaltamura/JMSJobQueueBundle that referenced this issue Dec 2, 2022
* Remove uneeded files

* Use UNIX line endings in all files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants