Re: Question about StartLogicalReplication() error path

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <rhaas(at)postgresql(dot)org>
Subject: Re: Question about StartLogicalReplication() error path
Date: 2021-06-11 04:43:07
Message-ID: CAA4eK1+SDBGQ6Ds6k-hb+Q27vOy6VJ+7AqCdaeCptg1_kX-38A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 11, 2021 at 7:38 AM Jeff Davis <pgsql(at)j-davis(dot)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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2021-06-11 04:55:46 Re: PoC/WIP: Extended statistics on expressions
Previous Message Michael Paquier 2021-06-11 04:19:33 Release 14 Beta 2