RE: [BUG]Update Toast data failure in logical replication
tanghy <tanghy.fnst@fujitsu.com>
From: "tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>
To: Amit Kapila <amit.kapila16@gmail.com>, Dilip Kumar <dilipbalaut@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, Euler Taveira <euler@eulerto.com>, Michael Paquier <michael@paquier.xyz>, 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>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-02-11T06:30:45Z
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 →
-
WAL log unchanged toasted replica identity key attributes.
- 5e01001ffb38 15.0 landed
- b5e060473273 10.21 landed
- 1cd5802ac69a 11.16 landed
- ce349cf176e2 12.11 landed
- caa231be97df 13.7 landed
- 04645bbcae72 14.3 landed
-
Add new wal_level, logical, sufficient for logical decoding.
- e55704d8b2fe 9.4.0 cited
-
Add the notion of REPLICA IDENTITY for a table.
- 07cacba983ef 9.4.0 cited
Attachments
- 13-v9-0001-WAL-log-unchanged-toasted-replica-identity-key-.patch (application/octet-stream) patch v9-0001
- 14-v9-0001-WAL-log-unchanged-toasted-replica-identity-key-.patch (application/octet-stream) patch v9-0001
- HEAD-v9-0001-WAL-log-unchanged-toasted-replica-identity-key-at.patch (application/octet-stream) patch v9-0001
- 10-v9-0001-WAL-log-unchanged-toasted-replica-identity-key-.patch (application/octet-stream) patch v9-0001
- 11-v9-0001-WAL-log-unchanged-toasted-replica-identity-key-.patch (application/octet-stream) patch v9-0001
- 12-v9-0001-WAL-log-unchanged-toasted-replica-identity-key-.patch (application/octet-stream) patch v9-0001
On Thu, Feb 10, 2022 9:34 PM Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> On Mon, Feb 7, 2022 at 1:27 PM Dilip Kumar <dilipbalaut@gmail.com> wrote:
> >
> > On Mon, Feb 7, 2022 at 12:25 PM Amit Kapila <amit.kapila16@gmail.com>
> wrote:
> > >
> > > Attached please find the modified patches.
> >
> > I have looked into the latest modification and back branch patches and
> > they look fine to me.
> >
>
> Today, while looking at this patch again, I think I see one problem
> with the below change (referring pg10 patch):
> + if (attrnum < 0)
> + {
> + if (attrnum != ObjectIdAttributeNumber &&
> + attrnum != TableOidAttributeNumber)
> + {
> + modified = bms_add_member(modified,
> + attrnum -
> + FirstLowInvalidHeapAttributeNumber);
> + continue;
> + }
> + }
> ...
> ...
> + /* No need to check attributes that can't be stored externally. */
> + if (isnull1 || TupleDescAttr(tupdesc, attrnum - 1)->attlen != -1)
> + continue;
>
> I think it is possible that we use TupleDescAttr for system attribute
> (in this case ObjectIdAttributeNumber/TableOidAttributeNumber) which
> will be wrong as it contains only user attributes, not system
> attributes. See comments atop TupleDescData.
>
> I think this check should be modified to if (attrnum < 0 || isnull1
> || TupleDescAttr(tupdesc, attrnum - 1)->attlen != -1). What do you
> think?
>
I agree with you.
> * Another minor comment:
> + if (!heap_attr_equals(RelationGetDescr(relation), attrnum, value1,
> + value2, isnull1, isnull2))
>
> I think here we can directly use tupdesc instead of RelationGetDescr(relation).
>
+1.
Attached the patches which fixed the above two comments and the first comment in
my previous mail [1], the rest is the same as before.
I ran the tests on all branches, they all passed as expected.
[1] https://www.postgresql.org/message-id/OS0PR01MB61134DD41BE6D986B9DB80CCFB2E9%40OS0PR01MB6113.jpnprd01.prod.outlook.com
Regards,
Tang