Bug 144 - replicate_partition stored procedure doesn't start replicating changes to the new table
Summary: replicate_partition stored procedure doesn't start replicating changes to the...
Status: RESOLVED WORKSFORME
Alias: None
Product: Slony-I
Classification: Unclassified
Component: stored procedures (show other bugs)
Version: 2.0
Hardware: PC Linux
: low enhancement
Assignee: Slony Bugs List
URL: http://slony.info/documentation/2.0/p...
Depends on:
Blocks:
 
Reported: 2010-07-27 08:27 UTC by Steve Singer
Modified: 2010-11-04 13:50 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Singer 2010-07-27 08:27:45 UTC
Create a set 1 and add table a to set 1 and subscribe at least one receiver to the set.

Then create an inherited table b (that inherits from a).

The http://www.slony.info/documentation/partitioning.html leads one to belive that you can do 

 SELECT _test.replicate_partition(2,'public','b','b_pkey','none');

and that seems to work (ie it gives no error) but it leaves slony in a not so good state.  

If you run this on the origin you get
-A row in sl_table with tab_altered=f.  B on the origin does NOT have hte log trigger installed
-This command does nto change sl_table on subscribers.

The issues I see are

-add_empty_table_to_replication calls setAddTable_int not setAddTable.
setAddTable_int does NOT create a SET_ADD_TABLE event so the subscriber is never told to change its state(sl_table)
-After calling setAddTable the add_empty_table_to_replication function calls alterTableRestore() on the table which deletes the log trigger.

Was there a reason for this?  Further to note, setAddTable will check to make sure the set is not subscribed (which it probably is, see the motiviation at the top of the documentation page linked above)

I think we want to replace teh alterTableRestore() call with a SET_ADD_TABLE create event
Comment 1 Christopher Browne 2010-08-04 10:58:17 UTC
I'm responsible for that one...

The missing piece is that that particular function expects to be run via EXECUTE SCRIPT.

If it is run thus, then it gets run on each node (so there's no need for a further event).

There may need to be some remediation relating to alterTableRestore().
Comment 2 Steve Singer 2010-08-25 11:48:03 UTC
Defer to 2.0.6.
Comment 3 Christopher Browne 2010-11-04 13:50:06 UTC
The documentation on partitioning is reasonably clear that this is to be run as part of an EXECUTE SCRIPT request, so it runs against all nodes.

I'll augment the functions' documentation to indicate the same.

Head:
http://git.postgresql.org/gitweb?p=slony1-engine.git;a=commit;h=5bd032e4942c71ee5ae23d7b6c263c8b8a598fb8

2.0:
http://git.postgresql.org/gitweb?p=slony1-engine.git;a=commit;h=56e603a5bfe876186afe4ef0b5f443f0c95c3411