local_archive strategy: race condition on shared archive.tar when deploying to multiple hosts in parallel #4232
Unanswered
rockschtar
asked this question in
Bugs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Deployer Version
v8.0.5
Target OS
Rocky Linux 9.7
Which PHP version are you using?
PHP 8.4
Content of deploy.php or deploy.yaml
Steps to reproduce
update_code_strategy: local_archive(see config above).--limit:dep deploy env=production --revision=<sha>deploy:update_codeon both hosts in parallel (default behavior).Expected: both hosts deploy successfully.
Actual: the host that finishes first deletes the shared local
archive.tar; the slower host then fails:The whole deploy then aborts via
deploy:failed.Root cause: in
recipe/deploy/update_code.php(v8.0.5), thelocal_archivebranch uses a single shared file$gitRoot/archive.tarfor all hosts:Every host process creates, uploads and finally
unlink()s the same local file. Besides theunlink()failure shown above, there are worse latentcraces: host B may re-rungit archive(rewriting the file) or delete it while host A is still mid-upload(), which could silently upload a truncatedcarchive.Workaround: deploy serially with
dep deploy ... --limit 1(ortask('deploy:update_code')->limit(1)).Suggested fix: use a per-host archive filename (e.g.
archive-{{alias}}.tar), or build the archive once before the host fan-out and clean it up after all hosts have finished.Beta Was this translation helpful? Give feedback.
All reactions