Closed
Description
Symfony version(s) affected
4.4.44, up to 6.1.x
Description
The race condition is appears when several processes are attempting to create a same Doctrine Proxy directory which does not yet exist and \RuntimeException
is thrown in \Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer
at line 53:
51 if (!is_dir($proxyCacheDir = $em->getConfiguration()->getProxyDir())) {
52 if (false === @mkdir($proxyCacheDir, 0777, true)) {
53 throw new \RuntimeException(sprintf('Unable to create the Doctrine Proxy directory "%s".', $proxyCacheDir));
54 }
How to reproduce
This issue is difficult to reproduce, as any concurrency-related issues are. It appears when several processes are attempting to create a directory which does not yet exist. Specifically, when one process is between !is_dir()
and @mkdir()
after another process has already managed to create the directory.
Possible Solution
Add an extra check to \Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer
to line 52:
52 if (false === @mkdir($proxyCacheDir, 0777, true) && !is_dir($proxyCacheDir)) {
Additional Context
No response