From: | Xing Guo <higuoxing(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Set appropriate processing mode for auxiliary processes. |
Date: | 2024-05-10 02:58:33 |
Message-ID: | CACpMh+DBHVT4xPGimzvex=wMdMLQEu9PYhT+kwwD2x2nu9dU_Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, May 9, 2024 at 11:19 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> > At first I was sure this was introduced by my refactorings in v17, but
> > in fact it's been like this forever. I agree that InitProcessing makes
> > much more sense. The ProcessingMode variable is initialized to
> > InitProcessing, so I think we can simply remove that line from
> > AuxiliaryProcessMainCommon(). There are existing
> > "SetProcessingMode(InitProcessing)" calls in other Main functions too
> > (AutoVacLauncherMain, BackgroundWorkerMain, etc.), and I think those can
> > also be removed.
>
> This only works if the postmaster can be trusted never to change the
> variable; else children could inherit some other value via fork().
> In that connection, it seems a bit scary that postmaster.c contains a
> couple of calls "SetProcessingMode(NormalProcessing)". It looks like
> they are in functions that should only be executed by child processes,
> but should we try to move them somewhere else?
After checking calls to "SetProcessingMode(NormalProcessing)" in the
postmaster.c, they are used in background worker specific functions
(BackgroundWorkerInitializeConnectionByOid and
BackgroundWorkerInitializeConnection). So I think it's a good idea to
move these functions to bgworker.c. Then, we can get rid of calling
"SetProcessingMode(NormalProcessing)" in postmaster.c.
I also noticed that there's an unnecessary call to
"BackgroundWorkerInitializeConnection" in worker_spi.c (The worker_spi
launcher has set the dboid correctly).
Best Regards,
Xing.
Attachment | Content-Type | Size |
---|---|---|
v4-0001-Move-bgworker-specific-logic-to-bgworker.c.patch | text/x-patch | 6.2 KB |
v4-0002-Remove-redundant-SetProcessingMode-InitProcessing.patch | text/x-patch | 3.5 KB |
v4-0003-Minor-improvement-to-connection-initialization-fo.patch | text/x-patch | 1.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | zaidagilist | 2024-05-10 03:14:57 | Re: |
Previous Message | Hayato Kuroda (Fujitsu) | 2024-05-10 02:09:19 | RE: Improving the latch handling between logical replication launcher and worker processes. |