| Slony-I 1.2.21 Documentation | ||||
|---|---|---|---|---|
| Prev | Fast Backward | Fast Forward | Next | |
Slony-I has had two "flavours" of trigger handling:
In versions up to 1.2, PostgreSQL had no awareness of replication, with the result that Slony-I needed to "hack" on the system catalog in order to deactivate, on subscribers, triggers that ought not to run.
This has had a number of somewhat painful side-effects including:
Corruption of the system catalog on subscribers, as existing triggers, that generally need to be hidden, are "hacked", via pg_catalog.pg_trigger, to point to the index being used by Slony-I as its "primary key".
The very same thing was true for rules.
This had the side-effect that pg_dump could not be used to pull proper schemas from subscriber nodes.
It introduced the need to take out exclusive locks on all replicated tables when processing Section 17 as triggers on each replicated table would need to be dropped and re-added during the course of processing.
In PostgreSQL version 8.3, there is new functionality where triggers and rules can have their behaviour altered via ALTER TABLE, and specify any of the following further trigger-related options:
DISABLE TRIGGER trigger_name
ENABLE TRIGGER trigger_name
ENABLE REPLICA TRIGGER trigger_name
ENABLE ALWAYS TRIGGER trigger_name
DISABLE RULE rewrite_rule_name
ENABLE RULE rewrite_rule_name
ENABLE REPLICA RULE rewrite_rule_name
ENABLE ALWAYS RULE rewrite_rule_name
A new GUC variable, session_replication_role controls whether the session is in origin, replica, or local mode, which then, in combination with the above enabling/disabling options, controls whether or not the trigger function actually runs.
We may characterize when triggers fire, under Slony-I replication, based on the following table; the same rules apply to PostgreSQL rules.
Table 1. Trigger Behaviour
| Trigger Form | When Established | Log Trigger | denyaccess Trigger | Action - origin | Action - replica | Action - local |
|---|---|---|---|---|---|---|
| DISABLE TRIGGER | User request | disabled on subscriber | enabled on subscriber | does not fire | does not fire | does not fire |
| ENABLE TRIGGER | Default>Varlena General Bits17.1. Changes that you might not want to process using EXECUTE SCRIPTWhile it is vitally necessary to use EXECUTE SCRIPT to propagate DDL modifications to tables that are being replicated, there are several sorts of changes that you might wish to handle some other way:
17.2. Testing DDL ChangesA method for testing DDL changes has been pointed out as a likely "best practice." You need to test DDL scripts in a non-destructive manner. The problem is that if nodes are, for whatever reason, at all out of sync, replication is likely to fall over, and this takes place at what is quite likely one of the most inconvenient times, namely the moment when you wanted it to work. You may indeed check to see if schema scripts work well or badly, by running them by hand, against each node, adding BEGIN; at the beginning, and ROLLBACK; at the end, so that the would-be changes roll back. If this script works OK on all of the nodes, that suggests that it should work fine everywhere if executed via slonik. If problems are encountered on some nodes, that will hopefully allow you to fix the state of affairs on those nodes so that the script will run without error.
|