Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-13 Thread Andres Freund
On 2021-08-05 19:56:49 -0700, Andres Freund wrote: > Done in the attached patch. I don't think we need to add more to the docs than > the flag being required? Pushed that patch now. If we want further additions to the docs we can do so separately.

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-09 Thread Michael Paquier
On Mon, Aug 09, 2021 at 11:07:14AM -0400, Robert Haas wrote: > On Thu, Aug 5, 2021 at 8:02 PM Tom Lane wrote: >> I think doing nothing is fine. Given the lack of complaints, we're >> more likely to break something than fix anything useful. > > +1. FWIW, the only interesting case I have in my pl

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-09 Thread Robert Haas
On Thu, Aug 5, 2021 at 8:02 PM Tom Lane wrote: > I think doing nothing is fine. Given the lack of complaints, we're > more likely to break something than fix anything useful. +1. -- Robert Haas EDB: http://www.enterprisedb.com

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-05 Thread Andres Freund
Hi, On 2021-08-05 20:02:02 -0400, Tom Lane wrote: > Andres Freund writes: > > First, what do we want to do with BGWORKER_SHMEM_ACCESS? I'm inclined to > > treat > > it as a required flag going forward. > > +1 > > > The second question is what we want to do in the backbranches. I think the > >

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-05 Thread Tom Lane
Andres Freund writes: > First, what do we want to do with BGWORKER_SHMEM_ACCESS? I'm inclined to treat > it as a required flag going forward. +1 > The second question is what we want to do in the backbranches. I think the > reasonable options are to do nothing, or to make !BGWORKER_SHMEM_ACCESS

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-05 Thread Andres Freund
Hi, On 2021-08-02 15:34:07 -0400, Alvaro Herrera wrote: > Ah, that makes sense. That doesn't sound super fragile, but it is odd > and it's probably a good argument for removing the feature, particularly > since nobody seems to be using it. ISTM we concluded that we should remove unconnected work

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-02 Thread Alvaro Herrera
On 2021-Aug-02, Andres Freund wrote: > On Mon, Aug 2, 2021, at 12:12, Alvaro Herrera wrote: > > Hmm, I don't remember that an shmem-unconnected bgworker first connected > > to it and then let go. It seems weird to do it that way. My intention, > > as far as I recall, is that they would just nev

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-02 Thread Andres Freund
Hi, On Mon, Aug 2, 2021, at 12:12, Alvaro Herrera wrote: > On 2021-Aug-02, Andres Freund wrote: > > I do think there's some potential gains in simplicity and robustness > > that are made mildly harder by a subprocess that first attaches and > > detaches from shm (it's the only case where we can't

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-02 Thread Alvaro Herrera
On 2021-Aug-02, Andres Freund wrote: > > When I included this case I was thinking in tasks which would just run > > stuff not directly connected to data. Something like a sub-daemon: say > > a connection pooler, which is a bgworker just so that it starts and > > stops together with postmaster, an

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-02 Thread Andres Freund
Hi, On Mon, Aug 2, 2021, at 11:08, Alvaro Herrera wrote: > On 2021-Aug-02, Tom Lane wrote: > > > Robert Haas writes: > > > If you're saying that this code has been 100% broken for 7 years and > > > nobody's noticed until now, then that suggests that nobody actually > > > uses non-shmem-connected

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-02 Thread Alvaro Herrera
On 2021-Aug-02, Tom Lane wrote: > Robert Haas writes: > > If you're saying that this code has been 100% broken for 7 years and > > nobody's noticed until now, then that suggests that nobody actually > > uses non-shmem-connected bgworkers. I sort of hate to give up on that > > concept but if we've

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-02 Thread Andres Freund
Hi, On 2021-08-02 11:00:49 -0400, Tom Lane wrote: > Robert Haas writes: > > If you're saying that this code has been 100% broken for 7 years and > > nobody's noticed until now, then that suggests that nobody actually > > uses non-shmem-connected bgworkers. I sort of hate to give up on that > > co

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-02 Thread Tom Lane
Robert Haas writes: > If you're saying that this code has been 100% broken for 7 years and > nobody's noticed until now, then that suggests that nobody actually > uses non-shmem-connected bgworkers. I sort of hate to give up on that > concept but if we've really gone that many years without anyone

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-02 Thread Robert Haas
On Mon, Aug 2, 2021 at 2:51 AM Andres Freund wrote: > which presents a problem: We've initialized all kind of references to shared > memory, own a PGPROC, but have detached from shared memory. > > In practice this will lead pretty quickly to a segfault, because process exit > will run proc_exit ca

Re: EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-02 Thread Andres Freund
Hi, On 2021-08-01 23:51:16 -0700, Andres Freund wrote: > In practice this will lead pretty quickly to a segfault, because process exit > will run proc_exit callbacks, which in turn will try to do a ProcKill(). Or > logging dereferences MyProc, or ... > > It seems the above code block would need t

EXEC_BACKEND vs bgworkers without BGWORKER_SHMEM_ACCESS

2021-08-01 Thread Andres Freund
Hi, While looking at a patch I noticed that SubPostmasterMain() for bgworkers unconditionally does /* Need a PGPROC to run CreateSharedMemoryAndSemaphores */ InitProcess(); which presents a problem, because StartBackgroundWorker() then does /* *