Jeff Trout threshar at torgo.978.org
Thu Dec 6 12:48:27 PST 2007
I'm running slony 1.2.8 (Yes, I realize there are newer releases,  
just haven't upgraded yet, and glancing over notes, it seems this  
wouldn't be a bug.)

So we've got a "master" db which feeds some common general  
information to some other systems, which in turn work with and off of  
the data. (these guys need their own copy of the data.. and slony  
seemed the most logical way to keep that all in sync). The data in  
this case is company info (cik, ticker, mcap, etc).

In one case we have a table that as a foreign key w/ondelete cascade  
into the replicated table. This works fine - inserting a row into the  
table fails if the key isn't there.  The problem is if data is  
deleted from the replicated table, it seems the ON DELETE CASCADE  
part is never done, and I'm left with orphaned nodes in my other tables.

cik is a PK in the companyinfo table, if_portfolio_ciks has a FK to  
it (on delete cascade).

PRODUCTION > insert into if_portfolio_ciks (portfolio_id, cik,  
dateposted, num_shares) values (20013, 103973, now(), 100);
ERROR:  insert or update on table "if_portfolio_ciks" violates  
foreign key constraint "if_portfolio_ciks_cik_fkey"
DETAIL:  Key (cik)=(103973) is not present in table "companyinfo".

so the FK part is fine.
On the master I inserted a record with cik 1000010266

back on the other box;

PRODUCTION > insert into if_portfolio_ciks (portfolio_id, cik,  
dateposted, num_shares) values (20013, 1000010266, now(), 100);
INSERT 0 1

[ I delete the companyinfo record on the master ]

PRODUCTION > select * from if_portfolio_ciks where portfolio_id = 20013;
  portfolio_id |    cik     |         dateposted         | num_shares
--------------+------------+----------------------------+------------
         20013 | 1000010266 | 2007-12-06 15:36:44.598798 |        100

PRODUCTION > select * from companyinfo where cik = 1000010266;
cik | ticker | name | mcap | ....
-----+--------+------+------+--------+-----------+------------- 
+----------+----------+----------+-----------+----------- 
+-------------+----------+----------+-----------+------------------- 
+----------+---------------
(0 rows)


Is this just the nature of the beast. I realize this may not be  
entirely under Slonys unbrella of how it is to be used, but I needed  
a way to distribute & sync data from a table to a number of other  
places. Which slony does do a good job of.

So, anything I can do?

--
Jeff Trout <jeff at jefftrout.com>
http://www.dellsmartexitin.com/
http://www.stuarthamm.net/





More information about the Slony1-general mailing list