Two Qustions: RSync Server load? Atomic Updates?

Matt McCutchen
Wed, 22 Aug 2007 23:31:45 -0000

On 8/22/07, doxburger <doxburger@gmail.com> wrote:
> 2) I will need to update my RSync server on a regular basis.  I have been
> using rsync to send data to the rsync server (makes sense right?).  Now and
> then a user has been downloading from the rsync server, as I am updating
the
> data set, and they get a mix  of the old and new update.  This completely
> breaks my application.  How is this handled normally?

I recommend the following technique:

1. Upload each new revision of the module contents to a new directory.
 (You can --link-dest from the existing contents.)
2. Make a symlink that always points to the latest revision.  Whenever
you finish uploading a new revision, atomically overwrite the symlink
to point to it.  (Note: "ln -fs module.5 module" is not atomic;
"ln -s
module.5 module.tmp && mv module.tmp module" is.)
3. Specify the symlink as the module path in your rsyncd.conf .

Each time the daemon gets a connection from a client, it will fork a
server process which will chdir through the symlink into the latest
revision of the module.  Subsequent changes to the symlink will not
affect the data seen by that connection.  Once you are pretty sure
that no open connections are using an old revision of a module, you
can delete the revision.

If you like, you can set up a special module on the daemon with
pre-xfer and post-xfer commands to carry out this technique and then
just upload to that module.

Matt