Re: [BUG]Update Toast data failure in logical replication

Alvaro Herrera <alvherre@alvh.no-ip.org>

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Dilip Kumar <dilipbalaut@gmail.com>, Petr Jelinek <petr.jelinek@enterprisedb.com>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Tomas Vondra <tomas.vondra@enterprisedb.com>, Andres Freund <andres@anarazel.de>, Kuntal Ghosh <kuntalghosh.2007@gmail.com>, "tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2021-08-10T14:38:48Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. WAL log unchanged toasted replica identity key attributes.

  2. Add new wal_level, logical, sufficient for logical decoding.

  3. Add the notion of REPLICA IDENTITY for a table.

On 2021-Jul-30, Amit Kapila wrote:

> I was thinking of using toast pointer but that won't work because it
> can be different on the subscriber-side. I don't see any better ideas
> to fix this issue. This problem seems to be from the time Logical
> Replication has been introduced, so adding others (who are generally
> involved in this area) to see what they think about this bug? I think
> people might not be using toasted columns for Replica Identity due to
> which this problem has been reported yet but I feel this is quite a
> fundamental issue and we should do something about this.

In the evening before going offline a week ago I was looking at this and
my conclusion was that this was a legitimate problem: the original
implementation is faulty in that the full detoasted value is required to
be transmitted in order for downstream to be able to read the value.

I am not sure if at the level of logical decoding it is a problem
theoretically, but at least for logical replication it is clearly a
practical problem.

Reading Dilip's last posted patch that day, I had some reservations
about the API of ExtractReplicaIdentity.  The new argument makes for a
very strange to explain behavior "return the key values if they are
unchanged, *or* if they are toasted" ... ???  I tried to make sense of
that, and tried to find a concept that would make sense to the whole,
but couldn't find any obvious angle in the short time I looked at it.
I haven't looked at it again.

-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"El Maquinismo fue proscrito so pena de cosquilleo hasta la muerte"
(Ijon Tichy en Viajes, Stanislaw Lem)