From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Re: [COMMITTERS] pgsql: Perform only one ReadControlFile() during startup. |
Date: | 2017-09-19 18:24:17 |
Message-ID: | 20170919182417.mf7xalft7e7veddi@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers pgsql-hackers |
On 2017-09-19 13:15:28 -0400, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > On 2017-09-19 13:00:33 -0400, Robert Haas wrote:
> >> You mean, in the postmaster?
>
> > Yes. We try to avoid touch shmem there, but it's not like we're
> > succeeding fully. See e.g. the pgstat_get_crashed_backend_activity()
> > calls (which do rely on shmem being ok to some extent), pmsignal,
> > BackgroundWorkerStateChange(), ...
>
> Well, the point is to avoid touching data structures that could be
> corrupted enough to confuse the postmaster. I don't have any problem with
> adding some more functionality to pmsignal, say.
Given that we're ok with reading pgstat shared memory entries, I think
adding a carefully coded variant of SendProcSignal() should be doable in
a safe manner.
Something roughly like
int
PostmasterSendProcSignal(pid_t pid, ProcSignalReason reason)
{
volatile ProcSignalSlot *slot;
/*
* As this is running in postmaster, be careful not to dereference
* any pointers from shared memory that could be corrupted, and to
* not to throw errors.
*/
for (i = 0; i < NumProcSignalSlots; i++)
{
slot = &ProcSignalSlots[i];
if (slot->pss_pid == pid)
{
/*
* The note about race conditions in SendProcSignal applies
* here, too
*/
/* Atomically set the proper flag */
slot->pss_signalFlags[reason] = true;
/* Send signal */
return kill(pid, SIGUSR1);
}
}
errno = ESRCH;
return -1;
}
As all the memory offsets are computed based on postmaster process-local
variables, this should be safe.
I'd rather like to avoid a copy of the procsignal infrastructure if we
don't need it...
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2017-09-19 18:47:26 | Re: Re: [COMMITTERS] pgsql: Add citext_pattern_ops for citext contrib module |
Previous Message | Andres Freund | 2017-09-19 17:42:32 | Re: pgsql: Add test for postmaster crash restarts. |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2017-09-19 18:29:31 | Re: Re: issue: record or row variable cannot be part of multiple-item INTO list |
Previous Message | Andres Freund | 2017-09-19 18:10:28 | Re: Running some tests with different segment sizes |