Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache conflict when executing pdepend in parallel #193

Closed
bvis opened this issue Mar 23, 2015 · 4 comments
Closed

Cache conflict when executing pdepend in parallel #193

bvis opened this issue Mar 23, 2015 · 4 comments
Assignees
Milestone

Comments

@bvis
Copy link

bvis commented Mar 23, 2015

From time to time there's a conflict when PDepends tries to flush the cache and there's another execution in parallel. The output I receive in a Jenkins job is something similar to:

phpmd-ci:
PHP Warning:  unlink(/var/lib/jenkins/.pdepend/cr/cr7ujpijhr4-ad7ikjyoew0-00-baila17gjw0.5.6.tokens): No such file or directory in /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php on line 220
PHP Stack trace:
PHP   1. {main}() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/bin/phpmd:0
PHP   2. PHPMD\TextUI\Command::main() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/bin/phpmd:122
PHP   3. PHPMD\TextUI\Command->run() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/main/php/PHPMD/TextUI/Command.php:175
PHP   4. PHPMD\PHPMD->processFiles() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/main/php/PHPMD/TextUI/Command.php:134
PHP   5. PHPMD\Parser->parse() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/main/php/PHPMD/PHPMD.php:222
PHP   6. PDepend\Engine->analyze() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/main/php/PHPMD/Parser.php:123
PHP   7. PDepend\Engine->performParseProcess() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php:318
PHP   8. PDepend\Util\Cache\CacheFactory->create() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php:558
PHP   9. PDepend\Util\Cache\CacheFactory->createCache() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/CacheFactory.php:94
PHP  10. PDepend\Util\Cache\CacheFactory->createFileCache() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/CacheFactory.php:113
PHP  11. PDepend\Util\Cache\Driver\FileCacheDriver->__construct() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/CacheFactory.php:131
PHP  12. PDepend\Util\Cache\Driver\File\FileCacheDirectory->__construct() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/FileCacheDriver.php:111
PHP  13. PDepend\Util\Cache\Driver\File\FileCacheDirectory->flush() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php:79
PHP  14. PDepend\Util\Cache\Driver\File\FileCacheDirectory->flushDirectory() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php:189
PHP  15. PDepend\Util\Cache\Driver\File\FileCacheDirectory->flushEntry() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php:203
PHP  16. PDepend\Util\Cache\Driver\File\FileCacheDirectory->flushDirectory() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php:222
PHP  17. PDepend\Util\Cache\Driver\File\FileCacheDirectory->flushEntry() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php:203
PHP  18. unlink() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php:220
PHP Warning:  rmdir(/var/lib/jenkins/.pdepend/cr): No such file or directory in /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php on line 223
PHP Stack trace:
PHP   1. {main}() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/bin/phpmd:0
PHP   2. PHPMD\TextUI\Command::main() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/bin/phpmd:122
PHP   3. PHPMD\TextUI\Command->run() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/main/php/PHPMD/TextUI/Command.php:175
PHP   4. PHPMD\PHPMD->processFiles() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/main/php/PHPMD/TextUI/Command.php:134
PHP   5. PHPMD\Parser->parse() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/main/php/PHPMD/PHPMD.php:222
PHP   6. PDepend\Engine->analyze() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/phpmd/phpmd/src/main/php/PHPMD/Parser.php:123
PHP   7. PDepend\Engine->performParseProcess() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php:318
PHP   8. PDepend\Util\Cache\CacheFactory->create() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Engine.php:558
PHP   9. PDepend\Util\Cache\CacheFactory->createCache() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/CacheFactory.php:94
PHP  10. PDepend\Util\Cache\CacheFactory->createFileCache() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/CacheFactory.php:113
PHP  11. PDepend\Util\Cache\Driver\FileCacheDriver->__construct() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/CacheFactory.php:131
PHP  12. PDepend\Util\Cache\Driver\File\FileCacheDirectory->__construct() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/FileCacheDriver.php:111
PHP  13. PDepend\Util\Cache\Driver\File\FileCacheDirectory->flush() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php:79
PHP  14. PDepend\Util\Cache\Driver\File\FileCacheDirectory->flushDirectory() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php:189
PHP  15. PDepend\Util\Cache\Driver\File\FileCacheDirectory->flushEntry() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php:203
PHP  16. rmdir() /var/lib/jenkins/jobs/MYPROJECT/workspace/vendor/pdepend/pdepend/src/main/php/PDepend/Util/Cache/Driver/File/FileCacheDirectory.php:223
Directory name must not be empty.
Result: 1

One possible solution would be to isolate the cache of PDepend not just per user as it is now, but for process. Do this is so easy, you just need to change in PDepend\DependencyInjection\Configuration(88):

->scalarNode('location')->defaultValue($home . '/.pdepend')->end()

By something like:

->scalarNode('location')->defaultValue($home . '/.pdepend/'.getmypid())->end()

But this has an undesired side effect, the implemented cache flush will not work correctly because each cache is saved in a separated directory that will probably never cleaned up by any later PDepend execution. It should be changed to check not just this cache directory that includes the PID, but the generic cache directory.

@bvis
Copy link
Author

bvis commented May 5, 2015

I think this is related with: #163
I'll reactivate my job execution parallelization to check if it fixed the problem.

@manuelpichler
Copy link
Contributor

Very sad, but this is an issue that came up several times before :( Using the pid is not a good idea because then pdepend would floud your file system.

Since the cache cleanup is not a critical thing, I will now try to fix this issue by letting unlink and rmdir silently fail.

@bvis
Copy link
Author

bvis commented May 21, 2015

Hi Manuel,

I can tell you that after the #163 fix I have not seen this problem again. I can't ensure that it can't be produced again but it's good to know!

@manuelpichler manuelpichler added this to the 2.2.0 milestone Sep 20, 2015
@manuelpichler manuelpichler self-assigned this Sep 20, 2015
@manuelpichler
Copy link
Contributor

FIxed in a4e20ff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants