pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe
6+ messages / 3 participants
[nested] [flat]

* pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe
@ 2022-06-21 02:50 Amit Kapila <akapila@postgresql.org>
  2022-06-21 04:12 ` Re: pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: Amit Kapila @ 2022-06-21 02:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix partition table's REPLICA IDENTITY checking on the subscriber.

In logical replication, we will check if the target table on the
subscriber is updatable by comparing the replica identity of the table on
the publisher with the table on the subscriber. When the target table is a
partitioned table, we only check its replica identity but not for the
partition tables. This leads to assertion failure while applying changes
for update/delete as we expect those to succeed only when the
corresponding partition table has a primary key or has a replica
identity defined.

Fix it by checking the replica identity of the partition table while
applying changes.

Reported-by: Shi Yu
Author: Shi Yu, Hou Zhijie
Reviewed-by: Amit Langote, Amit Kapila
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/26b3455afaa968fb48d0e468528d79de56624559

Modified Files
--------------
src/backend/replication/logical/relation.c | 115 +++++++++++++++++------------
src/backend/replication/logical/worker.c   |  27 +++++--
src/test/subscription/t/013_partition.pl   |  14 ++++
3 files changed, 101 insertions(+), 55 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe
  2022-06-21 02:50 pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Amit Kapila <akapila@postgresql.org>
@ 2022-06-21 04:12 ` Tom Lane <tgl@sss.pgh.pa.us>
  2022-06-21 04:27   ` Re: pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Amit Kapila <amit.kapila16@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2022-06-21 04:12 UTC (permalink / raw)
  To: Amit Kapila <akapila@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

Amit Kapila <akapila@postgresql.org> writes:
> Fix partition table's REPLICA IDENTITY checking on the subscriber.

prion seems not too happy with this --- probably you could reproduce
the failure with -DRELCACHE_FORCE_RELEASE -DCATCACHE_FORCE_RELEASE.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe
  2022-06-21 02:50 pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Amit Kapila <akapila@postgresql.org>
  2022-06-21 04:12 ` Re: pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Tom Lane <tgl@sss.pgh.pa.us>
@ 2022-06-21 04:27   ` Amit Kapila <amit.kapila16@gmail.com>
  2022-06-21 11:56     ` Re: pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Amit Kapila <amit.kapila16@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Amit Kapila @ 2022-06-21 04:27 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Amit Kapila <akapila@postgresql.org>; pgsql-committers <pgsql-committers@lists.postgresql.org>

On Tue, Jun 21, 2022 at 9:42 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Amit Kapila <akapila@postgresql.org> writes:
> > Fix partition table's REPLICA IDENTITY checking on the subscriber.
>
> prion seems not too happy with this --- probably you could reproduce
> the failure with -DRELCACHE_FORCE_RELEASE -DCATCACHE_FORCE_RELEASE.
>

Okay, I'll look into it.

-- 
With Regards,
Amit Kapila.





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe
  2022-06-21 02:50 pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Amit Kapila <akapila@postgresql.org>
  2022-06-21 04:12 ` Re: pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Tom Lane <tgl@sss.pgh.pa.us>
  2022-06-21 04:27   ` Re: pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Amit Kapila <amit.kapila16@gmail.com>
@ 2022-06-21 11:56     ` Amit Kapila <amit.kapila16@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Amit Kapila @ 2022-06-21 11:56 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Amit Kapila <akapila@postgresql.org>; pgsql-committers <pgsql-committers@lists.postgresql.org>

On Tue, Jun 21, 2022 at 9:57 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
>
> On Tue, Jun 21, 2022 at 9:42 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> >
> > Amit Kapila <akapila@postgresql.org> writes:
> > > Fix partition table's REPLICA IDENTITY checking on the subscriber.
> >
> > prion seems not too happy with this --- probably you could reproduce
> > the failure with -DRELCACHE_FORCE_RELEASE -DCATCACHE_FORCE_RELEASE.
> >
>
> Okay, I'll look into it.
>

I have pushed a fix for this and prion has passed in its latest run.

-- 
With Regards,
Amit Kapila.





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe
@ 2022-06-21 02:50 Amit Kapila <akapila@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Amit Kapila @ 2022-06-21 02:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix partition table's REPLICA IDENTITY checking on the subscriber.

In logical replication, we will check if the target table on the
subscriber is updatable by comparing the replica identity of the table on
the publisher with the table on the subscriber. When the target table is a
partitioned table, we only check its replica identity but not for the
partition tables. This leads to assertion failure while applying changes
for update/delete as we expect those to succeed only when the
corresponding partition table has a primary key or has a replica
identity defined.

Fix it by checking the replica identity of the partition table while
applying changes.

Reported-by: Shi Yu
Author: Shi Yu, Hou Zhijie
Reviewed-by: Amit Langote, Amit Kapila
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/52d5ea9adb010d0908e8962842571cd1f6c2d66c

Modified Files
--------------
src/backend/replication/logical/relation.c | 115 +++++++++++++++++------------
src/backend/replication/logical/worker.c   |  27 +++++--
src/test/subscription/t/013_partition.pl   |  16 +++-
3 files changed, 102 insertions(+), 56 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe
@ 2022-06-21 02:50 Amit Kapila <akapila@postgresql.org>
  0 siblings, 0 replies; 6+ messages in thread

From: Amit Kapila @ 2022-06-21 02:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix partition table's REPLICA IDENTITY checking on the subscriber.

In logical replication, we will check if the target table on the
subscriber is updatable by comparing the replica identity of the table on
the publisher with the table on the subscriber. When the target table is a
partitioned table, we only check its replica identity but not for the
partition tables. This leads to assertion failure while applying changes
for update/delete as we expect those to succeed only when the
corresponding partition table has a primary key or has a replica
identity defined.

Fix it by checking the replica identity of the partition table while
applying changes.

Reported-by: Shi Yu
Author: Shi Yu, Hou Zhijie
Reviewed-by: Amit Langote, Amit Kapila
Backpatch-through: 13, where it was introduced
Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5f113d60e9982b8d5a8c9b2e85dc82330d3c683a

Modified Files
--------------
src/backend/replication/logical/relation.c | 115 +++++++++++++++++------------
src/backend/replication/logical/worker.c   |  27 +++++--
src/test/subscription/t/013_partition.pl   |  16 +++-
3 files changed, 102 insertions(+), 56 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2022-06-21 11:56 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 02:50 pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Amit Kapila <akapila@postgresql.org>
2022-06-21 04:12 ` Tom Lane <tgl@sss.pgh.pa.us>
2022-06-21 04:27   ` Amit Kapila <amit.kapila16@gmail.com>
2022-06-21 11:56     ` Amit Kapila <amit.kapila16@gmail.com>
2022-06-21 02:50 pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Amit Kapila <akapila@postgresql.org>
2022-06-21 02:50 pgsql: Fix partition table's REPLICA IDENTITY checking on the subscribe Amit Kapila <akapila@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox