Re: Logical replication - schema change not invalidating the relation cache
От | vignesh C |
---|---|
Тема | Re: Logical replication - schema change not invalidating the relation cache |
Дата | |
Msg-id | CALDaNm2+cdw=Zcw511XTPL+G8f8WFZbRmsbv+O70veH65SU_Ug@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Logical replication - schema change not invalidating the relation cache (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: Logical replication - schema change not invalidating the relation cache
|
Список | pgsql-hackers |
On Fri, 6 Jan 2023 at 04:32, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > vignesh C <vignesh21@gmail.com> writes: > > On Thu, 5 Jan 2023 at 03:17, Tom Lane <tgl@sss.pgh.pa.us> wrote: > >> The bigger picture here though is that in examples such as the one > >> you gave at the top of the thread, it's not very clear to me that > >> there's *any* principled behavior. If the connection between publisher > >> and subscriber tables is only the relation name, fine ... but exactly > >> which relation name applies? > > > The connection between publisher and subscriber table is based on > > relation id, During the first change relid, relname and schema name > > from publisher will be sent to the subscriber. Subscriber stores these > > id, relname and schema name in the LogicalRepRelMap hash for which > > relation id is the key. Subsequent data received in the subscriber > > will use the relation id received from the publisher and apply the > > changes in the subscriber. > > 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 > > t/100_bugs.pl .. 6/? > # Failed test 'check data in subscriber sch2.t1 after schema rename' > # at t/100_bugs.pl line 361. > # got: '' > # expected: '3' > # Looks like you failed 1 test of 9. > t/100_bugs.pl .. Dubious, test returned 1 (wstat 256, 0x100) > Failed 1/9 subtests > > 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. I have modified the test to include 'ALTER SUBSCRIPTION ... REFRESH PUBLICATION' to get the new data. The test should expect 1 & 3 for sch2.t1 as the record with value 1 was already inserted before rename. The updated v6 patch has the changes for the same. Regards, Vignesh
Вложения
В списке pgsql-hackers по дате отправления: