Re: Logical replication - schema change not invalidating the relation cache

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Logical replication - schema change not invalidating the relation cache
Date: 2023-01-06 16:21:28
Message-ID: 3009750.1673022088@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

vignesh C <vignesh21(at)gmail(dot)com> writes:
> On Fri, 6 Jan 2023 at 04:32, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Hm. I spent some time cleaning up this patch, and found that there's
>> still a problem. ISTM that the row with value "3" ought to end up
>> in the subscriber's sch2.t1 table, but it does not: the attached
>> test script fails with
>> ...
>> What's up with that?

> When the subscription is created, the subscriber will create a
> subscription relation map of the corresponding relations from the
> publication. The subscription relation map will only have sch1.t1
> entry. As sch2.t1 was not present in the publisher when the
> subscription was created, subscription will not have this entry in the
> subscription relation map. So the insert operations performed on the
> new table sch2.t1 will not be applied by the subscriber. We will have
> to refresh the publication using 'ALTER SUBSCRIPTION ... REFRESH
> PUBLICATION' to fetch missing table information from publisher. This
> will start replication of tables that were added to the subscribed-to
> publications since CREATE SUBSCRIPTION or the last invocation of
> REFRESH PUBLICATION.

But ... but ... but ... that's the exact opposite of what the test
case shows to be happening. To wit, the newly created table
(the second coming of sch1.t1) *is* replicated immediately, while
the pre-existing t1 (now sch2.t1) is not. It's impossible to
explain those two facts under either a model of "tables are matched
by name" or "tables are matched by OID". So I'm still of the opinion
that there's some very dubious behavior here.

However, it does seem that the cache flush makes one aspect better,
so I pushed this after a little further work on the test case.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-01-06 16:29:31 Re: [PATCH] Expand character set for ltree labels
Previous Message Andrew Dunstan 2023-01-06 15:59:14 Re: [PATCH] Expand character set for ltree labels