The race condition is appears when several processes are attempting to create a same Doctrine Proxy/Hydrator directory which does not yet exist and \RuntimeException is thrown:
22 if (!is_dir($hydratorCacheDir)) {
23 if (false === @mkdir($hydratorCacheDir, 0775, true)) {
24 exit(sprintf('Unable to create the Doctrine Hydrator directory (%s)', dirname($hydratorCacheDir)));
25 }
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 !file_exists() and @mkdir() after another process has already managed to create the directory.
DoctrineMongoDBBundle version(s) affected
3.5.3, up to 4.6.x
Description
The race condition is appears when several processes are attempting to create a same Doctrine Proxy/Hydrator directory which does not yet exist and
\RuntimeException
is thrown:\Doctrine\Bundle\MongoDBBundle\CacheWarmer\ProxyCacheWarmer
\Doctrine\Bundle\MongoDBBundle\CacheWarmer\PersistentCollectionCacheWarmer
\Doctrine\Bundle\MongoDBBundle\CacheWarmer\HydratorCacheWarmer
\Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\CreateProxyDirectoryPass
\Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\CreateHydratorDirectoryPass
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
!file_exists()
and@mkdir()
after another process has already managed to create the directory.Possible Solution
Add an extra check
!file_exists()
. Example:\Doctrine\Bundle\MongoDBBundle\CacheWarmer\ProxyCacheWarmer
Additional Context
Same problem in symfony/symfony already was fixed - see issue #47489.