Andrew Sullivan ajs at crankycanuck.ca
Wed Jun 10 07:42:04 PDT 2009
On Mon, Jun 08, 2009 at 04:05:17PM +0000, owais at preceptglobalaccess.com wrote:
> I don't get it. Can you explain a bit more.
> 
> As i have 1 master and 1 slave. Then i run a toggle script that changes my slave to master and my master to slave.
> 
> Therefore, My previous slave is a new master.
> 
> Now, I want to toggle again. And it is giving me an error. What is wrong in it ?

You have the wrong model of how Slony works.

Nodes are not "master" or "slave" as such.  They're data sources for
particular sets (possibly being the origin for one set and a recipient
for some other set).  Therefore, running the same script the second
time will in fact just try to move the source of the target set from
the first node to the second node.  But you already did that when you
tried the first time, which means that your second attempt will not be
successful.

If you want a "toggle" script, then you need to write a script that
detects the _current_ state of the cluster based on what the various
nodes have configured (and you better check them all!), and then runs
the correct "move set" script(s) to move the set as it is currently
configured to a new origin.  Note that there are serious race
conditions here, and while Slony is designed to avoid letting you
break it (1) it is nevertheless possible to get it into a bad state
and (2) it is quite tricky to write a bulletproof script due to the races.

Slony has a lot of features, but this unfortunately means that a naive
"master-slave" installation still requires quite a bit of
understanding of the underlying sophisticated bits.  

The manual is pretty complete (although a little orotund) about how
this all works.  Look in particular at the "task oriented" segments,
and work through all the examples step by step (because there's no
"shortcut" documentation for Slony as far as I know).  This learning
curve problem is one of the barriers to Slony adoption, I'm afraid.

A


-- 
Andrew Sullivan
ajs at crankycanuck.ca


More information about the Slony1-general mailing list