Race-condition-free deployment with the "symlink replacement" trick
1–10 of 38 posts
Re: Race-condition-free deployment with the "symlink replacement" trick
#2Re: Race-condition-free deployment with the "symlink replacement" trick
#3Re: Race-condition-free deployment with the "symlink replacement" trick
#4Re: Race-condition-free deployment with the "symlink replacement" trick
#5Solving this in a way that doesn't require restarting any services and doesn't introduce any more race conditions is nontrivial, although it tends to work pretty reliably so long as you have a front controller and it very rarely changes. Basically it comes down to a symlink change detector by hitting a special (internal) URL after your deploy script which kills the stat cache. If people are interested I can post a more concrete example.
Re: Race-condition-free deployment with the "symlink replacement" trick
#6This seems a bit oversimplified. Sure, there are no race conditions if there are no interactions between files, but if there are then swapping the symlink mid-request on requests that are already in progress will cause all sorts of race conditions.
Re: Race-condition-free deployment with the "symlink replacement" trick
#7http://comments.gmane.org/gmane.os.solaris.opensolaris.zfs/2...
I would do a fsync() before switching the symlink to the new dir.
Re: Race-condition-free deployment with the "symlink replacement" trick
#8Yeah, mv is atomic but I believe that a crash can still leave your data inconsistent due to write reordering, see: http://comments.gmane.org/gmane.os.solaris.opensolaris.zfs/2... I would do a fsync() before switching the symlink to the new dir.
Re: Race-condition-free deployment with the "symlink replacement" trick
#9This is a good system at face value, but can present other problems. Any code that has a stat cache (I know PHP does, and I'd be surprised if other common languages don't) suddenly doesn't realize that your paths are going to a different place. Because /var/www as your "base" directory is symlinked to /var/www.a, www.a is cached and when you swap your symlink to www.b to deploy the next version, anything relying on t…
Because of the opcode issues we still do a rolling restart of the apaches but we don't see them a lot.
We use `rename` instead of `mv`. Don't know why :)
edit: this also handles the problem of suddenly referencing different files mid-request. Because you don't
Re: Race-condition-free deployment with the "symlink replacement" trick
#10I got the strange feeling from that article as if changing the code files was the hardest thing about yes upgrade.