Jan Wieck JanWieck
Thu Aug 26 20:56:20 PDT 2004
On 8/26/2004 4:45 PM, Alan Hodgson wrote:

> On Thu, Aug 26, 2004 at 03:37:38PM -0500, joe wrote:
>>         1. Alter tables don't seem to require any interaction with
>> slonik to be replicated, as long as the alter table statement(s) is/are
>> executed on all nodes before any queries (inserts, updates, deletes)
>> that use the new schema are run.  This doesn't feel quite safe (or sane)
>> to me and I was wondering how other people handle modifications to
>> existing tables.
> 
> Use the slonik command EXECUTE SCRIPT to do DDL changes.  Commands
> executed there will be applied to all nodes in a safe point in
> the replication sequence.
> 
> Ie.  create one file:
> 
> alter table blah add column new_column type;
> alter table blah alter column new_column set default good_default;
> 
> Execute a slonik script that executes those commands.
> 
> psql to your db, 
>   update blah set new_column = good_default where new_column is null;
> 
> Create another file:
> 
> alter table blah alter column new_column set not null;
> 
> Execute a slonik script that executes that command.

Or put all 4 commands (alter, alter, update, alter) into the first 
script and run only that :-)


Jan

> 
> This will all be done in the correct order for the replication, not
> interfering with other writes that may happen.
> 
>>         2. adding new tables to an existing replication set (apparantly)
>> requires unsubscribing that set, adding the table then re-subscribing
>> the set. This forces a full dump of the table (and possibly full set?)
>> when it happens. (Not fun when the table/set is several gigs). Do most
>> people just make a new table set when they add tables to the
>> source/master node or how do they deal with that situation?
>> 
> 
> Create a new set with the new table.
> Subscribe the same slave nodes to the new set that are subscribed to the
> old set.
> Wait for the subscribe to complete on the slave nodes.
> Execute the slonik MERGE SET command to merge the new set with the
> existing set.
> 
> 


-- 
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck at Yahoo.com #


More information about the Slony1-general mailing list