Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gvh9D-00042V-SP for pgsql-general@arkaria.postgresql.org; Mon, 18 Feb 2019 11:31:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gvh9C-000868-CN for pgsql-general@arkaria.postgresql.org; Mon, 18 Feb 2019 11:31:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gvh9C-000861-4S for pgsql-general@lists.postgresql.org; Mon, 18 Feb 2019 11:31:42 +0000 Received: from hermes.gatewaynet.com ([193.92.121.98]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gvh99-0001PR-E2 for pgsql-general@lists.postgresql.org; Mon, 18 Feb 2019 11:31:41 +0000 Received: from smadev.internal.net (pc131.internal.net [10.9.200.131]) by hermes.gatewaynet.com (8.14.3/8.14.3/Debian-9.4) with ESMTP id x1IBVVMN015502 for ; Mon, 18 Feb 2019 13:31:36 +0200 Received: from smadev.internal.net (smadev [10.9.200.131]) by smadev.internal.net (8.15.2/8.15.2) with ESMTP id x1IBVV5U085055 for ; Mon, 18 Feb 2019 13:31:31 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) Subject: Re: Slony and triggers on slavenodes. To: pgsql-general@lists.postgresql.org References: <89DE7C43D727C04CA77C8B7AB82533CD022B479B3D@WINVMSERV464.ad.smhi.se> From: Achilleas Mantzios Message-ID: Date: Mon, 18 Feb 2019 13:31:31 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.3.2 MIME-Version: 1.0 In-Reply-To: <89DE7C43D727C04CA77C8B7AB82533CD022B479B3D@WINVMSERV464.ad.smhi.se> Content-Type: multipart/alternative; boundary="------------EF5DFAD3BBE786D1A65475F9" Content-Language: en-US X-Virus-Scanned: clamav-milter 0.98.7 at hermes X-Virus-Status: Clean X-Spam-Status: No, score=-25.2 required=5.0 tests=ALL_TRUSTED,DYN_HAM_COORD, DYN_HAM_IT,DYN_HAM_NAUTICAL,DYN_SPAM_WATCHES8,HTML_MESSAGE, SARE_SPEC_REPLICA_OBFU autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on hermes.gatewaynet.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------EF5DFAD3BBE786D1A65475F9 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 18/2/19 1:09 μ.μ., Gustavsson Mikael wrote: > Hi, > > I have a Postgresql 11 and Slony 2.2.7 setup with one master and multiple slave nodes. On one of the slaves I want a user defined trigger to fire on insert. The trigger fires a notify function. > > Now to the problem. > > If I create the trigger it looks like it is enabled on the slave but it do not fire. > > CREATE TRIGGER >     AFTER INSERT >     ON >     FOR EACH ROW >     EXECUTE PROCEDURE ; > > If i try to enable it explicit with > > ALTER TABLE > ENABLE ALWAYS TRIGGER ; > > or > > ALTER TABLE > ENABLE REPLICA TRIGGER ; > > and then look at the table definition the trigger is disabled. How? can you show the output of \d ? or pg_dump -x --schema-only -t ? > > Is this expected behavior in slony? > I understand that this may be tricky in replication context and that the default behavior is that triggers on slaves are disabled. > > We have plans to move to logical replication which should solve this I assume, but it does not fit the schedule at the moment. > > KR > Mikael Gustavsson > -- Achilleas Mantzios IT DEV Lead IT DEPT Dynacom Tankers Mgmt --------------EF5DFAD3BBE786D1A65475F9 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit
On 18/2/19 1:09 μ.μ., Gustavsson Mikael wrote:
Hi,

I have a Postgresql 11 and Slony 2.2.7 setup with one master and multiple slave nodes. On one of the slaves I want a user defined trigger to fire on insert. The trigger fires a notify function.

Now to the problem.

If I create the trigger it looks like it is enabled on the slave but it do not fire.

CREATE TRIGGER <trigger_name>
    AFTER INSERT
    ON <table_name>
    FOR EACH ROW
    EXECUTE PROCEDURE <function_name>;

If i try to enable it explicit with

ALTER TABLE <table_name>
ENABLE ALWAYS TRIGGER <trigger_name>;

or

ALTER TABLE <table_name>
ENABLE REPLICA TRIGGER <trigger_name>;

and then look at the table definition the trigger is disabled.

How? can you show the output of \d ? or pg_dump -x --schema-only -t <table_name> ?


Is this expected behavior in slony?
I understand that this may be tricky in replication context and that the default behavior is that triggers on slaves are disabled.

We have plans to move to logical replication which should solve this I assume, but it does not fit the schedule at the moment.

KR
Mikael Gustavsson



-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt
--------------EF5DFAD3BBE786D1A65475F9--