RE: Added schema level support for publication.

From: "tanghy(dot)fnst(at)fujitsu(dot)com" <tanghy(dot)fnst(at)fujitsu(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: Rahila Syed <rahilasyed90(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Ajin Cherian <itsajin(at)gmail(dot)com>
Subject: RE: Added schema level support for publication.
Date: 2021-06-30 09:49:43
Message-ID: OS0PR01MB61138278359AE713EA24140DFB019@OS0PR01MB6113.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tuesday, June 29, 2021 11:25 AM tanghy(dot)fnst(at)fujitsu(dot)com <tanghy(dot)fnst(at)fujitsu(dot)com> wrote:
>
> Thanks for your patch. The warnings are fixed.
>
> But I found an issue while using your V8 patch, which is similar to [1]. The case
> is as below:
> Drop a schema from publication and refresh publication at subscriber, then
> insert into publisher table, the inserts still replicated to subscriber. The expect
> result is that the data is no longer replicated.
>

I also saw a problem while using "ALTER PUBLICATION ... ADD SCHEMA ...". The case is as below:
Add a schema to publication, then refresh publication at subscriber. Insert into publisher table, the inserts couldn't replicate to subscriber.

Steps to reproduce the case:
------publisher------
CREATE PUBLICATION testpub FOR SCHEMA public;

------subscriber------
CREATE SUBSCRIPTION testsub CONNECTION 'dbname=postgres port=5432' PUBLICATION testpub;

------publisher------
CREATE SCHEMA s1;
CREATE TABLE s1.t1 (a int PRIMARY KEY);
insert into s1.t1 values (1);
ALTER PUBLICATION testpub ADD SCHEMA s1;

------subscriber------
CREATE SCHEMA s1;
CREATE TABLE s1.t1 (a int PRIMARY KEY);
ALTER SUBSCRIPTION testsub REFRESH PUBLICATION;
postgres=# SELECT * FROM s1.t1;
a
---
1
(1 row)

------publisher------
insert into s1.t1 values (2);

------subscriber------
postgres=# SELECT * FROM s1.t1;
a
---
1
(1 row)

when I executed "ALTER PUBLICATION ... ADD TABLE ...", rel_sync_cache_publication_cb callback function set replicate_valid to false, then it would validate the entry in get_rel_sync_entry function, and marked the pubactions to true. so it worked ok.

In the case of "ALTER PUBLICATION ... ADD SCHEMA ...", replicate_valid would not be set to false. Because of this, the pubactions were still false in get_rel_sync_entry function.
So I think the reason for it is similar to the one I reported before [1].

[1] https://www.postgresql.org/message-id/OS0PR01MB61134B20314DE45795DD384CFB029%40OS0PR01MB6113.jpnprd01.prod.outlook.com

Regards
Tang

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabien COELHO 2021-06-30 09:55:38 Re: pgbench logging broken by time logic changes
Previous Message Peter Smith 2021-06-30 09:47:10 Re: [HACKERS] logical decoding of two-phase transactions