On Fri, Jan 24, 2025 at 5:43 PM Sergey Tatarintsev <s.tatarint...@postgrespro.ru> wrote: > > I think there is another problem - publisher can modify publication > during the execution of "CREATE SUBSCRIPTION" (Rarely, this situation > occurred in my tests.) > > I.e.: > > 1. Publisher: CREATE PUBLICATION ... FOR TABLE t1; > > 2. Subscriber (starts CREATE SUBSCRIPTION ...): check_publications_origin() > > 3. Publisher: ALTER PUBLICATION ... ADD TABLE t2; > > 4. Subscriber (still process CREATE SUBSCRIPTION ...): fetch_table_list() > > So, we check publication with only t1, but fetch t1,t2 > > I think we must start transaction on publisher while executing > CreateSubscription() on subscriber (Or may be take an lock on publisher ) >
We don't want to make the code complex for this, especially in back-branches as that can introduce more bugs. We already document that "... it is the user's responsibility to make the necessary checks to ensure the copied data origins are really as wanted or not.". We should try to give this WARNING in possible scenarios without complicating the code too much. Anyway, even after this WARNING it is possible that the data is not copied from the publisher and there is no danger of copying the wrong origin. So, I suggest leaving the above case as it is. -- With Regards, Amit Kapila.