Re: releasing ParallelApplyTxnHash when pa_launch_parallel_worker returns NULL

From: Ted Yu <yuzhihong(at)gmail(dot)com>
To: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>
Cc: "akapila(at)postgresql(dot)org" <akapila(at)postgresql(dot)org>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: releasing ParallelApplyTxnHash when pa_launch_parallel_worker returns NULL
Date: 2023-01-11 02:20:54
Message-ID: CALte62yU-=b8XyNCJbHOj2g=OmqtO=tjStNsNmFqWK4ceEjs+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 10, 2023 at 6:13 PM houzj(dot)fnst(at)fujitsu(dot)com <
houzj(dot)fnst(at)fujitsu(dot)com> wrote:

> On Wednesday, January 11, 2023 1:25 AM Ted Yu <yuzhihong(at)gmail(dot)com> wrote:
>
> > I was reading src/backend/replication/logical/applyparallelworker.c .
> > In `pa_allocate_worker`, when pa_launch_parallel_worker returns NULL, I
> think the `ParallelApplyTxnHash` should be released.
>
> Thanks for reporting.
>
> ParallelApplyTxnHash is used to cache the state of streaming transactions
> being
> applied. There could be multiple streaming transactions being applied in
> parallel and their information were already saved in ParallelApplyTxnHash,
> so
> we should not release them just because we don't have a worker available to
> handle a new transaction here.
>
> Best Regards,
> Hou zj
>
Hi,

/* First time through, initialize parallel apply worker state
hashtable. */
if (!ParallelApplyTxnHash)

I think it would be better if `ParallelApplyTxnHash` is created by the
first successful parallel apply worker.

Please take a look at the new patch and see if it makes sense.

Cheers

Attachment Content-Type Size
create-parallel-apply-txn-hash-after-the-first-worker.patch application/octet-stream 875 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-01-11 02:26:17 Re: pgsql: Add new GUC createrole_self_grant.
Previous Message Amit Kapila 2023-01-11 02:16:42 Re: Handle infinite recursion in logical replication setup