swooletw / laravel-swoole

High performance HTTP server based on Swoole. Speed up your Laravel or Lumen applications.
MIT License
4.04k stars 390 forks source link

Doctrine EntityManager lost db connection #432

Closed bogvsdev closed 3 years ago

bogvsdev commented 4 years ago

When running laravel swoole on server along with "laravel-doctrine/orm": "1.6.*" found that it's entity manager can loose connection and that would block whole application from correct work. Only restarting swoole server can resolve this issue.

While examining this issue found similar problem for symfony and solution https://github.com/pixelfederation/doctrine-resettable-em-bundle. The question is how can I add similar solution to laravel when it's running on swoole?

  1. Please provide your PHP and Swoole version. (php -v and php --ri swoole)

PHP 7.4.8, Swoole 4.5.2

  1. Please provide your Laravel/Lumen version.

Laravel Framework 7.20

  1. Which release version of this package are you using?

Version 2.6

  1. What did you do? If possible, provide a recipe for reproducing the error. Used app functionality and nothing that would harm swoole server or mysql server.

  2. What did you expect to see?

Working application

  1. What did you see instead?

Database connection errors in application and error in swoole_http.log WARNING swSignalfd_onSignal (ERRNO 707): Unable to find callback function for signal Broken pipe: 13

Arkanius commented 4 years ago

Try to check this out: https://alejandrocelaya.blog/2019/11/04/how-to-properly-handle-a-doctrine-entity-manager-on-an-expressive-application-served-with-swoole/