Hg server replication

Matt Mackall mpm at selenic.com
Wed Nov 7 16:04:36 UTC 2007


On Tue, Nov 06, 2007 at 08:34:28PM -0800, Wing Choi wrote:
> 
> I am using svk (with Pushmi) and that is sort of what it does now.
> There isn't a lock server, it does a reserve ahead with the primary
> (obviously, any other simultaneous push attempts that does not get
> the reserve ahead will back off and that/those user(s) will have
> to pull and merge b4 retrying the push) and then replay the
> transaction over to the primary once the push from the local
> client is complete.
> 
> How can something similar be accomplished in Hg?

To do it right, you need a hook to grab a global lock before the push
begins, and a hook to do the sync and release the lock after. This can
be done with ssh and a simple shell script. Managing a lock is as
easy as this:

server-a$ ssh lockserver "ln -s `hostname` lock 2>/dev/null" || echo fail

server-b$ ssh lockserver "ln -s `hostname` lock 2>/dev/null" || echo fail
fail

But this all defeats the purpose of using a distributed system,
because you now have a central server that you have to keep in sync
with and wait for a potentially long time to get a lock on. As the
number of committers rise with a centralized server, the lock
contention will very rapidly approach 100%.

A distributed system simply accepts that you will be out of sync with
other developers and makes merging with them an easy process.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial mailing list