Re: Perform streaming logical transactions by background workers and parallel apply

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: "kuroda(dot)hayato(at)fujitsu(dot)com" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: "wangw(dot)fnst(at)fujitsu(dot)com" <wangw(dot)fnst(at)fujitsu(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, "shiy(dot)fnst(at)fujitsu(dot)com" <shiy(dot)fnst(at)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Perform streaming logical transactions by background workers and parallel apply
Date: 2022-08-23 04:20:08
Message-ID: CAHut+Put2aFA1zA=sdLgwCG1AZFxWx5G2t5tsGbu_9QXscGLBw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Aug 22, 2022 at 10:49 PM kuroda(dot)hayato(at)fujitsu(dot)com
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>

> 04. launcher.c
>
> 04.a
>
> + worker->main_worker_pid = is_subworker ? MyProcPid : 0;
>
> You can use InvalidPid instead of 0.
> (I thought pid should be represented by the datatype pid_t, but in some codes it is defined as int...)
>
> 04.b
>
> + worker->main_worker_pid = 0;
>
> You can use InvalidPid instead of 0, same as above.
>
> 05. origin.c
>
> void
> -replorigin_session_setup(RepOriginId node)
> +replorigin_session_setup(RepOriginId node, int acquired_by)
>
> IIUC the same slot can be used only when the apply main worker has already acquired the slot
> and the subworker for the same subscription tries to acquire, but it cannot understand from comments.
> How about adding comments, or an assertion that acquired_by is same as session_replication_state->acquired_by ?
> Moreover acquired_by should be compared with InvalidPid, based on above comments.
>

In general I agree, and I also suggested to use pid_t and InvalidPid
(at least for all the new code)

In practice, please be aware that InvalidPid is -1 (not 0), so
replacing any existing code (e.g. in replorigin_session_setup) that
was already checking for 0 has to be done with lots of care.

------
Kind Regards,
Peter Smith.
Fujitsu Australia.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2022-08-23 04:21:40 Re: logical decoding and replication of sequences
Previous Message Michael Paquier 2022-08-23 04:16:31 Re: ICU for global collation