{"action":"created","issue":{"url":"https://api.github.com/repos/php-pm/php-pm/issues/391","repository_url":"https://api.github.com/repos/php-pm/php-pm","labels_url":"https://api.github.com/repos/php-pm/php-pm/issues/391/labels{/name}","comments_url":"https://api.github.com/repos/php-pm/php-pm/issues/391/comments","events_url":"https://api.github.com/repos/php-pm/php-pm/issues/391/events","html_url":"https://github.com/php-pm/php-pm/issues/391","id":331910155,"node_id":"MDU6SXNzdWUzMzE5MTAxNTU=","number":391,"title":"Database connection may be lost when a worker is idle for too long","user":{"login":"bpolaszek","id":5569077,"node_id":"MDQ6VXNlcjU1NjkwNzc=","avatar_url":"https://avatars0.githubusercontent.com/u/5569077?v=4","gravatar_id":"","url":"https://api.github.com/users/bpolaszek","html_url":"https://github.com/bpolaszek","followers_url":"https://api.github.com/users/bpolaszek/followers","following_url":"https://api.github.com/users/bpolaszek/following{/other_user}","gists_url":"https://api.github.com/users/bpolaszek/gists{/gist_id}","starred_url":"https://api.github.com/users/bpolaszek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpolaszek/subscriptions","organizations_url":"https://api.github.com/users/bpolaszek/orgs","repos_url":"https://api.github.com/users/bpolaszek/repos","events_url":"https://api.github.com/users/bpolaszek/events{/privacy}","received_events_url":"https://api.github.com/users/bpolaszek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-13T09:19:41Z","updated_at":"2018-06-13T10:35:30Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Following #387 \r\n\r\nI'm encountering the following issue: I have a SF 4.1 application delivered by PHP-PM, which has near 0 traffic for the moment. The problem is, when a worker gets no traffic for x amount of time, it can encounter a `General error: 2006 MySQL server has gone away` error, and throw a 500 error.\r\n\r\nThis is because by default, MySQL kills any connection that has been idle for too long. And I have to say: fortunately.\r\n\r\nI think this can be tuned in MySQL by changing `wait_timeout`'s value, but this means that if I deploy my app to another server and I forget about this, the same issue may appear again. \r\n\r\nIsn't there another solution that could be handled either on PHP-PM side, either on the application side? \r\n\r\nWhat I'm thinking of are:\r\n\r\n- A worker could have a maximum time alive (and/or idle) defined in `ppm.json`. Like the `max-requests` option, a worker could be reloaded when the limit has been reached\r\n- The application could hook into the event loop to \"ping\" the database regularly. I don't think if it's technically possible, but that could be an option.\r\n\r\nAny ideas?\r\n\r\nThank you,\r\nBen"},"comment":{"url":"https://api.github.com/repos/php-pm/php-pm/issues/comments/396892638","html_url":"https://github.com/php-pm/php-pm/issues/391#issuecomment-396892638","issue_url":"https://api.github.com/repos/php-pm/php-pm/issues/391","id":396892638,"node_id":"MDEyOklzc3VlQ29tbWVudDM5Njg5MjYzOA==","user":{"login":"bpolaszek","id":5569077,"node_id":"MDQ6VXNlcjU1NjkwNzc=","avatar_url":"https://avatars0.githubusercontent.com/u/5569077?v=4","gravatar_id":"","url":"https://api.github.com/users/bpolaszek","html_url":"https://github.com/bpolaszek","followers_url":"https://api.github.com/users/bpolaszek/followers","following_url":"https://api.github.com/users/bpolaszek/following{/other_user}","gists_url":"https://api.github.com/users/bpolaszek/gists{/gist_id}","starred_url":"https://api.github.com/users/bpolaszek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpolaszek/subscriptions","organizations_url":"https://api.github.com/users/bpolaszek/orgs","repos_url":"https://api.github.com/users/bpolaszek/repos","events_url":"https://api.github.com/users/bpolaszek/events{/privacy}","received_events_url":"https://api.github.com/users/bpolaszek/received_events","type":"User","site_admin":false},"created_at":"2018-06-13T10:35:30Z","updated_at":"2018-06-13T10:35:30Z","author_association":"CONTRIBUTOR","body":"I'm using Doctrine too. Do you have a snippet I could try? In my application, Doctrine is booted by Symfony 4 and called in a ParamConverter (which allows entity type-hinting in controllers). \r\n\r\nWhen `Sensio\\Bundle\\FrameworkExtraBundle\\Request\\ParamConverter\\DoctrineParamConverter` tries to convert my URL params into entities, it calls the `ManagerRegistry`, finds the correct Manager for the entity to be retrieved, and fetches it. "}}
{"actor":{"display_login":"bpolaszek"}}