From: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: unexpected behavior with pglogical -- bug?
Date: Wed, 19 Jun 2019 11:46:43 +0300
Message-ID: <a96f0657-2d2f-455b-6b9f-8b851a6e7603@matrix.gatewaynet.com> (raw)
In-Reply-To: <CAKkG4_n6LG2N_1EYq3n8swCosWo3H85AM9xWfTxC7626qVX8+Q@mail.gmail.com>
References: <CAKkG4_n6LG2N_1EYq3n8swCosWo3H85AM9xWfTxC7626qVX8+Q@mail.gmail.com>
Hello
have you tried the same with logical replication in postgresql >= 10?
On 16/6/19 11:45 μ.μ., Torsten Förtsch wrote:
> Hi,
>
> out of curiosity I created the following setup, all with 9.6 and pglogical.
>
> D1 is configured as provider with a replication set that contains only 1 table. Only inserts are replicated.
>
> D2 is configured as subscriber for that replication set. Replication works, all inserts on D2 arrive also on D2.
>
> Now, I add the following always firing trigger to the table:
>
> CREATE OR REPLACE FUNCTION notify.trgfn () RETURNS trigger AS $def$
> BEGIN
> PERFORM pg_notify(NEW.channel, NEW.msg);
> RETURN NULL;
> END
> $def$ LANGUAGE plpgsql;
>
> CREATE TRIGGER trg BEFORE INSERT ON notify.notify
> FOR EACH ROW
> EXECUTE PROCEDURE notify.trgfn();
>
> ALTER TABLE notify.notify ENABLE ALWAYS TRIGGER trg;
>
> As you can see, the trigger function should prevent the actual insert and only call pg_notify(). In principle this works but there is a catch. Notifications generated this way are only delivered
> after another notification genuinely generated on the subscriber node. The channel of this notification does not matter. If I replace PERFORM pg_notify() by RAISE NOTICE I see the message
> immediately in the log.
>
> First I thought this is related to session_replication_role=replica. So, I tried the direct insert on D2 with this setting using psql. The notification was fired immediately. Also, whether the
> trigger prevents or allows the actual insert does not matter. I tried to create the trigger function as SECURITY DEFINER and with a specific search_path. That didn't help either.
>
> By now I am thinking there must be something missing in pglogical.
>
> Thanks,
> Torsten
--
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: achill@matrix.gatewaynet.com
Subject: Re: unexpected behavior with pglogical -- bug?
In-Reply-To: <a96f0657-2d2f-455b-6b9f-8b851a6e7603@matrix.gatewaynet.com>
References: <CAKkG4_n6LG2N_1EYq3n8swCosWo3H85AM9xWfTxC7626qVX8+Q@mail.gmail.com> <a96f0657-2d2f-455b-6b9f-8b851a6e7603@matrix.gatewaynet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox