Re: [HACKERS] Weaker shmem interlock w/o postmaster.pid

From: Noah Misch <noah(at)leadboat(dot)com>
To: Daniel Gustafsson <daniel(at)yesql(dot)se>
Cc: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, "9erthalion6(at)gmail(dot)com" <9erthalion6(at)gmail(dot)com>, "sfrost(at)snowman(dot)net" <sfrost(at)snowman(dot)net>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Weaker shmem interlock w/o postmaster.pid
Date: 2019-03-31 22:42:33
Message-ID: 20190331224233.GC891537@rfd.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Mar 29, 2019 at 09:53:51AM +0000, Daniel Gustafsson wrote:
> On Saturday, March 9, 2019 8:16 AM, Noah Misch <noah(at)leadboat(dot)com> wrote:
> > I renamed IpcMemoryAnalyze() to PGSharedMemoryAttach() and deleted the old
> > function of that name. Now, this function never calls shmdt(); the caller is
> > responsible for that. I do like things better this way. What do you think?
>
> I think it makes for a good API for the caller to be responsible, but it does
> warrant a comment on the function to explicitly state that.

The name "PGSharedMemoryAttach" makes that fact sufficiently obvious, I think.

> A few other small comments:
>
> + state = PGSharedMemoryAttach((IpcMemoryId) id2, &memAddress);
> + if (memAddress)
> + shmdt(memAddress);
>
> This seems like a case where it would be useful to log a shmdt() error or do
> an Assert() around the success of the operation perhaps?

I'll add the same elog(LOG) we have at other shmdt() sites. I can't think of
a site where we Assert() about the results of a system call. While shmdt()
might be a justified exception, elog(LOG) seems reasonable.

> + * Loop till we find a free IPC key. Trust CreateDataDirLockFile() to
> + * ensure no more than one postmaster per data directory can enter this
> + * loop simultaneously. (CreateDataDirLockFile() does not ensure that,
> + * but prefer fixing it over coping here.)
>
> This comment make it seem like there is a fix to CreateLockFile() missing to
> his patch, is that correct? If so, do you have an idea for that patch?

That comment refers to
https://postgr.es/m/flat/20120803145635.GE9683%40tornado.leadboat.com

> Switching this to Ready for Committer since I can't see anything but tiny things.

Thanks.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ideriha, Takeshi 2019-03-31 23:44:23 RE: idle-in-transaction timeout error does not give a hint
Previous Message Noah Misch 2019-03-31 22:31:58 Re: [HACKERS] WAL logging problem in 9.4.3?