Jan Wieck JanWieck at Yahoo.com
Wed Nov 19 05:39:49 PST 2008
On 10/27/2008 2:04 PM, Michael Lorenz wrote:
> OK, so blowing away all of the records in sl_event *did* get  
> replication started again.
> 
> However, as I said in the original post, this is not something I want  
> to try in production.  Can anyone provide any information as to how to  
> get Slony back on track when replication gets messed up as I described  
> below?  Of particular use would be how to identify problem sl_event  
> records (if doing that is the best way).

The best way is not to mess it up like that.

The docs have been wrong about how to wait for a SUBSCRIBE SET. The 
trick is that subscribing to a set involves an event that is not 
generated by any slonik script, but by the sets Origin when it receives 
the SUBSCRIBE_SET event. That is the event to wait for. Another annoying 
detail is that WAIT FOR EVENT has a default timeout, and since 
subscribing can take a while, timeouts are bad. So assuming that set 1 
has Origin 1 and direct subscriber 2 with cascaded subscriber 3, the 
proper sequence of slonik commands to subscribe and merge another set is 
this:

     SUBSCRIBE SET (ID = 999, PROVIDER = 1, RECEIVER = 2);
     WAIT FOR EVENT (ORIGIN = 2, CONFIRMED = 1, WAIT ON = 1,
                     TIMEOUT = 0);
     SYNC (ID = 1);
     WAIT FOR EVENT (ORIGIN = 1, CONFIRMED = 2, WAIT ON = 1,
                     TIMEOUT = 0);

     SUBSCRIBE SET (ID = 999, PROVIDER = 2, RECEIVER = 3);
     WAIT FOR EVENT (ORIGIN = 3, CONFIRMED = 1, WAIT ON = 1,
                     TIMEOUT = 0);
     SYNC (ID=1);
     WAIT FOR EVENT (ORIGIN = 1, CONFIRMED = 3, WAIT ON = 1,
                     TIMEOUT = 0);
     MERGE SET ( ID = 1, ADD ID = 999, ORIGIN = 1 );

The WAIT after the SUBSCRIBE must wait until the SUBSCRIBE_SET has been 
processed by the Origin of the set, which means that the 
ENABLE_SUBSCRIPTION event has been created by the Origin. The following 
SYNC and WAIT then generate another event on the Origin which is known 
to slonik, and which it waits for to be processed by the new subscriber. 
When that is done, the subscriber not only has done the subscription 
itself but also the initial SYNC after that.


Jan

-- 
Anyone who trades liberty for security deserves neither
liberty nor security. -- Benjamin Franklin



More information about the Slony1-general mailing list