Skip to content

MySQL server has gone away from cron scheduler #178

@Xymanek

Description

@Xymanek

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)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions