Thread: pgsql: Allow pgoutput to send logical decoding messages.

pgsql: Allow pgoutput to send logical decoding messages.

From
Amit Kapila
Date:
Allow pgoutput to send logical decoding messages.

The output plugin accepts a new parameter (messages) that controls if
logical decoding messages are written into the replication stream. It is
useful for those clients that use pgoutput as an output plugin and needs
to process messages that were written by pg_logical_emit_message().

Although logical streaming replication protocol supports logical
decoding messages now, logical replication does not use this feature yet.

Author: David Pirotte, Euler Taveira
Reviewed-by: Euler Taveira, Andres Freund, Ashutosh Bapat, Amit Kapila
Discussion: https://postgr.es/m/CADK3HHJ-+9SO7KuRLH=9Wa1rAo60Yreq1GFNkH_kd0=CdaWM+A@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ac4645c0157fc5fcef0af8ff571512aa284a2cec

Modified Files
--------------
doc/src/sgml/protocol.sgml                  |  76 ++++++++++++++
src/backend/replication/logical/proto.c     |  28 ++++++
src/backend/replication/logical/worker.c    |   9 ++
src/backend/replication/pgoutput/pgoutput.c |  47 +++++++++
src/include/replication/logicalproto.h      |   3 +
src/include/replication/pgoutput.h          |   1 +
src/test/subscription/t/020_messages.pl     | 148 ++++++++++++++++++++++++++++
7 files changed, 312 insertions(+)


Re: pgsql: Allow pgoutput to send logical decoding messages.

From
Amit Kapila
Date:
On Tue, Apr 6, 2021 at 8:55 AM Amit Kapila <akapila@postgresql.org> wrote:
>
> Allow pgoutput to send logical decoding messages.
>

One of the tests added by this commit is failing:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sidewinder&dt=2021-04-06%2005%3A45%3A20

I think there is a race condition in one of the tests. I'll analyze
this further.

-- 
With Regards,
Amit Kapila.



Re: pgsql: Allow pgoutput to send logical decoding messages.

From
Amit Kapila
Date:
On Tue, Apr 6, 2021 at 2:12 PM Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> On Tue, Apr 6, 2021 at 8:55 AM Amit Kapila <akapila@postgresql.org> wrote:
> >
> > Allow pgoutput to send logical decoding messages.
> >
>
> One of the tests added by this commit is failing:
> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sidewinder&dt=2021-04-06%2005%3A45%3A20
>
> I think there is a race condition in one of the tests. I'll analyze
> this further.
>

As this is a timing issue so not easy to reproduce but as per my
analysis in the tests, after disabling the subscription, we were not
waiting for the replication connection to drop from the publisher. So
later when the test was trying to use the same slot to fetch the
messages via SQL API, it sometimes gives an error that the replication
slot is active for other PID. I have pushed a fix for this.

-- 
With Regards,
Amit Kapila.