From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Noah Misch <noah@leadboat.com>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Unexpected "shared memory block is still in use"
Date: Fri, 16 Aug 2019 10:18:58 -0400
Message-ID: <11212.1565965138@sss.pgh.pa.us> (raw)
In-Reply-To: <8cd56b77-dfd9-cfbe-cad2-663939b5f510@2ndquadrant.com>
References: <22224.1557340366@sss.pgh.pa.us>
<20190509055414.GB1066859@rfd.leadboat.com>
<2663.1557409654@sss.pgh.pa.us>
<2226.1557439179@sss.pgh.pa.us>
<17642.1557442078@sss.pgh.pa.us>
<20190510072213.GA1098093@rfd.leadboat.com>
<25485.1557500141@sss.pgh.pa.us>
<16908.1557521200@sss.pgh.pa.us>
<20190511190715.GA1124997@rfd.leadboat.com>
<29530.1565738526@sss.pgh.pa.us>
<8cd56b77-dfd9-cfbe-cad2-663939b5f510@2ndquadrant.com>
Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
> On 2019-08-14 01:22, Tom Lane wrote:
>> Attached is a draft patch to change both shmem and sema key selection
>> to be based on data directory inode rather than port.
> For the POSIX APIs where the numbers are just converted to a string, why
> not use both -- or forget about the inodes and use the actual data
> directory string.
Considering that we still need an operation equivalent to "nextSemKey++"
(in case of a key collision), I'm not really sure how working with strings
rather than ints would make life better.
> For the SYSV APIs, the scenario that came to my mind is if someone
> starts a bunch of servers each on their own mount, it could happen that
> the inodes of the data directories are very similar.
Sure. That's why I didn't throw away any of the duplicate-key-handling
logic, and why we're still checking for st_dev match when inspecting
particular shmem blocks. (It also seems likely that somebody
who's doing that would be using similar pathnames on the different
mounts, so that string-based approaches wouldn't exactly be free of
collision problems either.)
> There is also the issue that AFAICT the key_t in the SYSV APIs is always
> 32-bit whereas inodes are 64-bit. Probably not a big deal, but it might
> prevent an exact one-to-one mapping.
True, although the width of inode numbers is probably pretty platform-
and filesystem-dependent. We could consider trying some more complicated
mapping like xor'ing high and low halves, but I don't entirely see what
it buys us.
> Of course, ftok() is also available here as an existing solution.
I looked at that briefly, but I don't really see what it'd buy us either,
except for opacity which doesn't seem useful. The Linux man page pretty
much says in so many words that it's a wrapper for st_ino and st_dev;
and how does it help us if other platforms do it differently?
(Actually, if Linux does it the way the man page suggests, it'd really
be a net negative, because there'd only be 24 bits of key variation
not 32.)
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, peter.eisentraut@2ndquadrant.com, noah@leadboat.com, pgsql-hackers@lists.postgresql.org
Subject: Re: Unexpected "shared memory block is still in use"
In-Reply-To: <11212.1565965138@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox