From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Chapman Flack <chap(at)anastigmatix(dot)net> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, James Sewell <james(dot)sewell(at)jirotech(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Threading in BGWorkers (!) |
Date: | 2020-06-24 02:06:07 |
Message-ID: | 20200624020607.gxh7hf5srgek2g4q@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2020-06-23 21:50:26 -0400, Chapman Flack wrote:
> On 06/23/20 21:44, Andres Freund wrote:
>
> > I think that's way harder than what you make it sound here. The locking
> > for shm_mq doesn't really work inside a process. In contrast to the
> > single threaded case something like a volatile write to
> > ParallelMessagePending doesn't guarantee much, because there's no
> > guaranteed memory ordering between threads. And more.
>
> It occurred to me after I sent the message this morning that my suggestion
> (2) could subsume (1). And requires nothing more than a single volatile
> write of a boolean, and getting called back at a convenient time on the
> single main thread.
A single volatile write wouldn't guarantee you much in the presence of
multiple threads. You could very well end up with a concurrent
CHECK_FOR_INTERRUPTS() in the main thread unsetting InterruptPending,
but not yet seeing / processing ParallelMessagePending. Nor would it
wake up the main process if it's currently waiting on a latch.
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2020-06-24 02:11:10 | Re: Removal of currtid()/currtid2() and some table AM cleanup |
Previous Message | Chapman Flack | 2020-06-24 01:50:26 | Re: Threading in BGWorkers (!) |