Re: Question about StartLogicalReplication() error path - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: Question about StartLogicalReplication() error path
Date
Msg-id CAA4eK1+SDBGQ6Ds6k-hb+Q27vOy6VJ+7AqCdaeCptg1_kX-38A@mail.gmail.com
Whole thread Raw
In response to Question about StartLogicalReplication() error path  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Question about StartLogicalReplication() error path  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-hackers
On Fri, Jun 11, 2021 at 7:38 AM Jeff Davis <pgsql@j-davis.com> wrote:
>
> StartLogicalReplication() calls CreateDecodingContext(), which says:
>
>   else if (start_lsn < slot->data.confirmed_flush)
>   {
>     /*
>      * It might seem like we should error out in this case, but it's
>      * pretty common for a client to acknowledge a LSN it doesn't
> have to
>      * do anything for, and thus didn't store persistently, because the
>      * xlog records didn't result in anything relevant for logical
>      * decoding. Clients have to be able to do that to support
> synchronous
>      * replication.
>      */
>      ...
>      start_lsn = slot->data.confirmed_flush;
>   }
>
..
..
>
> I'm not sure I understand the comment overall. Why would the client
> request something that it has already acknowledged,
>

Because sometimes clients don't have to do anything for xlog records.
One example is WAL for DDL where logical decoding didn't produce
anything for the client but later with keepalive we send the LSN of
WAL where DDL has finished and the client just responds with the
position sent by the server as it doesn't have any other pending
transactions.

> and why would the
> server override that and just advance to the confirmed_lsn?
>

I think because there is no need to process the WAL that has been
confirmed by the client. Do you see any problems with this scheme?

-- 
With Regards,
Amit Kapila.



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Release 14 Beta 2
Next
From: Noah Misch
Date:
Subject: Re: PoC/WIP: Extended statistics on expressions