Andrew Sullivan ajs at crankycanuck.ca
Mon Jan 25 06:39:51 PST 2010
On Sat, Jan 23, 2010 at 01:58:18PM +0100, Benjamin Pineau wrote:

> Looking quickly at slony's source code, I thought this may be sufficient to
> run my ALTERs on replicated tables, avoiding an heavyweight "EXECUTE SCRIPT":
>                                                          
>                                                          
>   BEGIN;                                                 
>   LOCK TABLE mytable;                                    
>   -- Wait for pending events touching this table to propagate on subscribers.
>   -- Then run the same "BEGIN ; LOCK TABLE mytable;" on all subscribers.
> 
>   -- On all nodes
>   ALTER mytable ...
> 
>   -- On origin node (only there?)
>   SELECT _mycluster.alterTableRestore(42);
>   SELECT _mycluster.alterTableForReplication(42);
> 
>   -- On all nodes (origin and subscribers)
>   COMMIT;
> 
> 
> Would this work or did I overlooked something?

This is actually what Slony does.  So it will work.  But it still
locks everything, note.

> I wonder if the alterTableRestore and alterTableForReplication are mandatory
> on subscribers, or only on origin. EXECUTE SCRIPT run them everywhere but
> this doesn't look necessary when we're not touching triggers/rewrites (?).

It's mandatory.  If you don't do this, the slony triggers themselves
get confused and Bad Things happen.

You need to do everything _last_ on the origin node because if it gets
the extra column at a logical point in transaction history time when
any of the replicas aren't ready for such a column, then that replica
will be broken.

> And I'm not sure whether it would be wise to stop slon daemons meanwhile. My
> understanding is that when avoiding ddlScript_complete(), aforementioned
> actions wouldn't generate any event, so slon wouldn't notice anything.

Stopping the slons isn't the important bit, because they just apply
the records according to the state of the database at the time the
transactions happened.  AFAIR, you can leave them running.

I encourage you very strongly to test everything out in a lab first,
several times, before you do any of this.

A

-- 
Andrew Sullivan
ajs at crankycanuck.ca


More information about the Slony1-general mailing list