Skip to content

Conversation

RobinGeuze
Copy link

This solves errors like these:

 Child process error (exit code 1): PHP Warning:  rename(/app/tmp/cache/phpstan/cache/nette.configurator/Container_37633cd6c1.php.tmp,/app/tmp/cache/phpstan/cache/nette.configurator/Container_37633cd6c1.php): No such file or   
     directory in phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerLoader.php on line 68                                                                                                                
     Warning: rename(/app/tmp/cache/phpstan/cache/nette.configurator/Container_37633cd6c1.php.tmp,/app/tmp/cache/phpstan/cache/nette.configurator/Container_37633cd6c1.php): No such file or directory in                              
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerLoader.php on line 68                                                                                                                             
                                                                                                                                                                                                                                       
     In ContainerLoader.php line 71:                                                                                                                                                                                                   
                                                                                                                                                                                                                                       
       Unable to create file '/app/tmp/cache/phpstan/cache/nette.configurator/Container_37633cd6c1.php'.                                                                                                                               
                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                       
     worker [-c|--configuration CONFIGURATION] [-l|--level LEVEL] [-a|--autoload-file AUTOLOAD-FILE] [--memory-limit MEMORY-LIMIT] [--xdebug] [--port PORT] [--identifier IDENTIFIER] [--tmp-file TMP-FILE] [--instead-of INSTEAD-OF]  
     [--] [<paths>...]                                                                                                                                                                                                                 
                                                                                                                                                                                                                                       
      while running parallel worker                 

This is caused by the journal code deleting the file (because it hasn't been added to the journal yet) while another process is creating it. Since the container php files are quite large the file_put_contents call lasts quite long, and an unlink will work while file_put_contents is running. This then causes the rename to fail since the file has been deleted.

…oved in one process while its created in another
@staabm
Copy link
Contributor

staabm commented Sep 11, 2025

do you know steps how to reproduce the reported problem? would be great to have it documented for the future in case we need to look into similar things again.

@RobinGeuze
Copy link
Author

Unfortunately not, it is a race condition. Once it happens it seems to keep happening, but I've never been able to pinpoint precisely what causes it. It also seems to specifically happen when running phpstan within a docker desktop on mac container with the primary filesystem being a volume mount, but I've got no concrete proof that is required for the error to occur. The race condition in the code is quite obvious though.

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

Successfully merging this pull request may close these issues.

2 participants