Skip to content

Daemonizable Command Mysql Problem #9

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

Closed
ghost opened this issue May 5, 2014 · 3 comments
Closed

Daemonizable Command Mysql Problem #9

ghost opened this issue May 5, 2014 · 3 comments

Comments

@ghost
Copy link

ghost commented May 5, 2014

im using the daemonizable command bundle to read my queue's data, and use doctrine2 to persist to databases, but when run a long time, i got a exception "MySQL server has gone away". i found some information in google, it seem is the mysql connect timeout issue. So i want konw do you has some solutions to solve this problem?

@Donjohn
Copy link

Donjohn commented May 20, 2014

in the long command process, try catch the exception (DBAL one) and then create a reconnect function in your entity manager extended class.

public function reConnect($force=false)
{

    if (!$this->em->getConnection()->isConnected() || $force) {
        $this->em->getConnection()->close();
        $this->em->getConnection()->connect();
    }

    if (!$this->em->isOpen()) {
        $this->em = $this->em->create(
            $this->em->getConnection(),
            $this->em->getConfiguration()
        );
    }
}

@velikanov
Copy link

+1, you need to do it by hand

@mac-cain13
Copy link
Owner

Yes indeed, you need to check if the connection is still alive since it will time out and reconnect if needed.

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

No branches or pull requests

3 participants