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

From: "wangw(dot)fnst(at)fujitsu(dot)com" <wangw(dot)fnst(at)fujitsu(dot)com>
To: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>, "shiy(dot)fnst(at)fujitsu(dot)com" <shiy(dot)fnst(at)fujitsu(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: [PATCH] Reuse Workers and Replication Slots during Logical Replication
Date: 2023-02-07 07:28:33
Message-ID: OS3PR01MB62759EDA8D95BDFF092A99BA9EDB9@OS3PR01MB6275.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 1, 2023 20:07 PM Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com> wrote:
> Thanks for pointing out this review. I somehow skipped that, sorry.
>
> Please see attached patches.

Thanks for updating the patch set.
Here are some comments.

1. In the function ApplyWorkerMain.
+ /* This is main apply worker */
+ run_apply_worker(&options, myslotname, originname, sizeof(originname), &origin_startpos);

I think we need to keep the worker name as "leader apply worker" in the comment
like the current HEAD.

---

2. In the function LogicalRepApplyLoop.
+ * can be reused, we need to take care of memory contexts here
+ * before moving to sync a table.
+ */
+ if (MyLogicalRepWorker->ready_to_reuse)
+ {
+ MemoryContextResetAndDeleteChildren(ApplyMessageContext);
+ MemoryContextSwitchTo(TopMemoryContext);
+ return;
+ }

I think in this case we also need to pop the error context stack before
returning. Otherwise, I think we might use the wrong callback
(apply error_callback) after we return from this function.

---

3. About the function UpdateSubscriptionRelReplicationSlot.
This newly introduced function UpdateSubscriptionRelReplicationSlot does not
seem to be invoked. Do we need this function?

Regards,
Wang Wei

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2023-02-07 07:37:14 Re: Perform streaming logical transactions by background workers and parallel apply
Previous Message Peter Eisentraut 2023-02-07 07:18:53 Re: OpenSSL 3.0.0 vs old branches