Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication

From: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: Peter Smith <smithpb2250(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, "Wei Wang (Fujitsu)" <wangw(dot)fnst(at)fujitsu(dot)com>, "Yu Shi (Fujitsu)" <shiy(dot)fnst(at)fujitsu(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Subject: Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication
Date: 2023-07-04 19:47:34
Message-ID: CAGPVpCQiPeCi+xZ3uHfyGd94DSt7DYVGhJpC+0N1uV4KbZ7D-g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Hayato Kuroda (Fujitsu) <kuroda(dot)hayato(at)fujitsu(dot)com>, 27 Haz 2023 Sal,
10:42 tarihinde şunu yazdı:
>
> Dear Melih,
>
> Thank you for updating the patch! I have not reviewed yet, but I wanted
> to reply your comments.
>
> > This actually makes sense. I quickly try to do that without adding any
> > new replication message. As you would expect, it did not work.
> > I don't really know what's needed to make a connection to last for
> > more than one iteration. Need to look into this. Happy to hear any
> > suggestions and thoughts.
>
> I have analyzed how we handle this. Please see attached the patch (0003) which
> allows reusing connection. The patchset passed tests on my CI.
> To make cfbot happy I reassigned the patch number.
>
> In this patch, the tablesync worker does not call clean_sync_worker() at the end
> of iterations, and the establishment of the connection is done only once.
> The creation of memory context is also suppressed.
>
> Regarding the walsender, streamingDone{Sending|Receiving} is now initialized
> before executing StartLogicalReplication(). These flags have been used to decide
> when the process exits copy mode. The default value is false, and they are set
> to true when the copy mode is finished.
> I think there was no use-case that the same walsender executes START_REPLICATION
> replication twice so there were no codes for restoring flags. Please tell me if any other
> reasons.

Thanks for the 0003 patch. But it did not work for me. Can you create
a subscription successfully with patch 0003 applied?
I get the following error: " ERROR: table copy could not start
transaction on publisher: another command is already in progress".

I think streaming needs to be ended before moving to another table. So
I changed the patch a little bit and also addressed the reviews from
recent emails. Please see the attached patch set.

I'm still keeping the reuse connection patch separate for now to see
what is needed clearly.

Thanks,
Melih

Attachment Content-Type Size
v2-0001-Refactor-to-split-Apply-and-Tablesync-Workers.patch application/octet-stream 21.4 KB
v4-0002-Reuse-Tablesync-Workers.patch application/octet-stream 10.6 KB
v3-0003-reuse-connection-when-tablesync-workers-change-the-t.patch application/octet-stream 7.6 KB
v12-0004-Add-replication-protocol-cmd-to-create-a-snapshot.patch application/octet-stream 21.1 KB
v15-0005-Reuse-Replication-Slot-and-Origin-in-Tablesync.patch application/octet-stream 54.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Melih Mutlu 2023-07-04 20:18:14 Re: [PATCH] Reuse Workers and Replication Slots during Logical Replication
Previous Message Soumyadeep Chakraborty 2023-07-04 19:25:33 Re: brininsert optimization opportunity