Re: releasing ParallelApplyTxnHash when pa_launch_parallel_worker returns NULL

From: Ted Yu <yuzhihong(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, "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-12 02:55:18
Message-ID: CALte62y7NzEzXQqxg0a2ao3ntsKKyzXV0uy8ARfDyZff-se7wQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 11, 2023 at 6:54 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:

> On Wed, Jan 11, 2023 at 9:31 AM Ted Yu <yuzhihong(at)gmail(dot)com> wrote:
> >
> > On Tue, Jan 10, 2023 at 7:55 PM houzj(dot)fnst(at)fujitsu(dot)com <
> houzj(dot)fnst(at)fujitsu(dot)com> wrote:
> >>
> >> On Wednesday, January 11, 2023 10:21 AM Ted Yu <yuzhihong(at)gmail(dot)com>
> wrote:
> >> > /* 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.
> >>
> >> Thanks for the suggestion. But I am not sure if it's worth to changing
> the
> >> order here, because It will only optimize the case where user enable
> parallel
> >> apply but never get an available worker which should be rare. And in
> such a
> >> case, it'd be better to increase the number of workers or disable the
> parallel mode.
> >>
> >
> >
> > I think even though the chance is rare, we shouldn't leak resource.
> >
>
> But that is true iff we are never able to start the worker. Anyway, I
> think it is probably fine either way but we can change it as per your
> suggestion to make it more robust and probably for the code clarity
> sake. I'll push this tomorrow unless someone thinks otherwise.
>
> --
> With Regards,
> Amit Kapila.
>

Thanks Amit for the confirmation.

Cheers

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2023-01-12 03:00:22 Re: ATTACH PARTITION seems to ignore column generation status
Previous Message Amit Kapila 2023-01-12 02:54:07 Re: releasing ParallelApplyTxnHash when pa_launch_parallel_worker returns NULL