{"action":"created","issue":{"url":"https://api.github.com/repos/drush-ops/drush/issues/1141","labels_url":"https://api.github.com/repos/drush-ops/drush/issues/1141/labels{/name}","comments_url":"https://api.github.com/repos/drush-ops/drush/issues/1141/comments","events_url":"https://api.github.com/repos/drush-ops/drush/issues/1141/events","html_url":"https://github.com/drush-ops/drush/issues/1141","id":56368617,"number":1141,"title":"Concurrent drush execution intermittently throws errors","user":{"login":"Fabio-E-Questionmark","id":6928689,"avatar_url":"https://avatars.githubusercontent.com/u/6928689?v=3","gravatar_id":"","url":"https://api.github.com/users/Fabio-E-Questionmark","html_url":"https://github.com/Fabio-E-Questionmark","followers_url":"https://api.github.com/users/Fabio-E-Questionmark/followers","following_url":"https://api.github.com/users/Fabio-E-Questionmark/following{/other_user}","gists_url":"https://api.github.com/users/Fabio-E-Questionmark/gists{/gist_id}","starred_url":"https://api.github.com/users/Fabio-E-Questionmark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fabio-E-Questionmark/subscriptions","organizations_url":"https://api.github.com/users/Fabio-E-Questionmark/orgs","repos_url":"https://api.github.com/users/Fabio-E-Questionmark/repos","events_url":"https://api.github.com/users/Fabio-E-Questionmark/events{/privacy}","received_events_url":"https://api.github.com/users/Fabio-E-Questionmark/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-02-03T12:00:42Z","updated_at":"2015-03-19T14:55:18Z","closed_at":null,"body":"Hello.\r\n\r\nOur deployment strategy concurrently runs multiple Drush commands (using the same user) in a multi-threaded environment.\r\n\r\nThis works fine and helped to significantly improve performances, however, we are experiencing the following error (thrown intermittently):\r\nDrush must have a writable cache directory; please insure that one of the following \r\nlocations is writable...\r\n\r\nThe cache directory actually exists and appears to be writable.\r\nAlso, some Drush processes actually used it as cache data appears to be in it.\r\n\r\nBy looking at the drush_directory_cache function, the theory is that if a process calls \"is_writable\" exactly at the same time the directory is getting created, then is_writable returns FALSE and this causes drush_directory_cache to throw an error (if no other paths are available).\r\n\r\nIf this is true, I think the cleanest way to fix this issue would be to use semaphores to guarantee a mutually exclusive access.\r\n\r\nWould you think this would fix the problem / would you consider to accept a pull request with such a fix?\r\nAlso my question is, can you think about other potential problems caused by running concurrent Drush commands with the same user?\r\n\r\nThanks in advance for the support and for this great tool!\r\n\r\nFabio"},"comment":{"url":"https://api.github.com/repos/drush-ops/drush/issues/comments/83615246","html_url":"https://github.com/drush-ops/drush/issues/1141#issuecomment-83615246","issue_url":"https://api.github.com/repos/drush-ops/drush/issues/1141","id":83615246,"user":{"login":"Fabio-E-Questionmark","id":6928689,"avatar_url":"https://avatars.githubusercontent.com/u/6928689?v=3","gravatar_id":"","url":"https://api.github.com/users/Fabio-E-Questionmark","html_url":"https://github.com/Fabio-E-Questionmark","followers_url":"https://api.github.com/users/Fabio-E-Questionmark/followers","following_url":"https://api.github.com/users/Fabio-E-Questionmark/following{/other_user}","gists_url":"https://api.github.com/users/Fabio-E-Questionmark/gists{/gist_id}","starred_url":"https://api.github.com/users/Fabio-E-Questionmark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Fabio-E-Questionmark/subscriptions","organizations_url":"https://api.github.com/users/Fabio-E-Questionmark/orgs","repos_url":"https://api.github.com/users/Fabio-E-Questionmark/repos","events_url":"https://api.github.com/users/Fabio-E-Questionmark/events{/privacy}","received_events_url":"https://api.github.com/users/Fabio-E-Questionmark/received_events","type":"User","site_admin":false},"created_at":"2015-03-19T14:55:18Z","updated_at":"2015-03-19T14:55:18Z","body":"I believe I have just found the issue.\r\n\r\nThanks @weitzman, your last 2 questions really put me on the right track!\r\n\r\nTests were on *Windows*. But the actual issue was that \"sites/modules\" is a *symbolic link* pointing to somewhere else on the file system.\r\nAfter removing the link and copying the actual modules folder to sites/all/modules I could not replicate the issue anymore.\r\nNo deadlocks, no warnings.\r\n\r\nI'm not sure whether this is a Windows issue or a PHP / symbolic links issue, but this has clearly fixed the problem. It would be interesting to repeat the test on Linux using symbolic links though...\r\n\r\nSo, I can eventually come back to my original concern, which is only related to the Drush cache directory.\r\n\r\nConsidering the parallel execution of the following 4 commands:\r\n\r\ndrush -l test1 vget\r\ndrush -l test2 cc all\r\ndrush -l test3 another-command\r\ndrush -l test4 yet-another-command\r\n\r\nMy concern is that while cc is destroying the Drush cache, other commands are attempting to read it.\r\n\r\nThe \"immediate\" solution I see here, is to use the process ID to construct the Drush cache directory name. Perhaps not an elegant solution, but cheap and safe IMO.\r\n\r\nAny thought?\r\n\r\nMany thanks to everyone for the support!\r\n\r\nFabio"}}