We have a large yii2 application, which ran perfectly in a Debian Docker container with nginx + PHP-FPM 7.3 and opcache enabled.
After upgrading to PHP 7.4.10, some requests result in '(Connection reset by peer) while reading response header from upstream' errors. Disabling opcache solves the problem, but this is not really an option. I can also leave opcache enabled and blacklist the whole yii2 vendor folder, but this is also not an option.
We have also a non-docker PHP-FPM 7.4 + nginx + opcache installation on a Debian VM, this seam to run so far without such errors. But we need the Docker environment for development and later switching to docker in production.
Running the tests with PHP 7.3 + opcache took about 12 minutes, now without opcache 30 minutes(!).
I tried and was not successful:
We have the problem on all of our developer machines, like Mac notebooks, Windows notebooks and Linux notebooks using Ubuntu or Fedora.
My environment:
If anyone has some suggestions and even know how to solve the issue.
Update:
I configured my local system to run php-fpm 7.4.10 and configured the nginx in the docker container to use my local (on host) php-fpm. I got no errors or “Connection reset by peer” events.
So for me it seams to be a problem with docker and opcache.
Does anyone know what yii2 is doing when opcache is enabled and maybe how configure it?
Update: Now I also have back trace from gdb for the segmentation fault:
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `php-fpm: pool www '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 zend_gc_delref (p=0x6341203a79726156) at ./Zend/zend_types.h:1041
1041 ./Zend/zend_types.h: No such file or directory.
(gdb) bt
#0 zend_gc_delref (p=0x6341203a79726156) at ./Zend/zend_types.h:1041
#1 i_zval_ptr_dtor (zval_ptr=<optimized out>) at ./Zend/zend_variables.h:43
#2 zval_ptr_dtor (zval_ptr=<optimized out>) at ./Zend/zend_variables.c:84
#3 0x000055fd4809a88c in user_shutdown_function_dtor (zv=<optimized out>) at ./ext/standard/basic_functions.c:5048
#4 0x000055fd48177a25 in zend_hash_destroy (ht=0x7f961acb1150) at ./Zend/zend_hash.c:1541
#5 0x000055fd480a0515 in php_free_shutdown_functions () at ./ext/standard/basic_functions.c:5174
#6 0x000055fd48106445 in php_request_shutdown (dummy=<optimized out>) at ./main/main.c:1905
#7 0x000055fd47fd14dd in main (argc=<optimized out>, argv=<optimized out>) at ./sapi/fpm/fpm/fpm_main.c:1970
The back trace lead me to the solution, it is the pcov module.
Disabling it did the trick.
I was mislead by search result for segmentation faults which pointed to opcache and the changes made to opcache in PHP 7.4 and the pcov module was also enabled when using PHP 7.3 + opcache.
For now I'm lucky it works again with the new PHP version-
As we only need pcov to generate code coverage reports and we can disable opcache for code coverage report creation.
If anyone knows more about pcov + opcache + PHP 7.4, please leave a comment.