From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> |
Cc: | Noah Misch <noah(at)leadboat(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Unexpected "shared memory block is still in use" |
Date: | 2019-08-16 14:18:58 |
Message-ID: | 11212.1565965138@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Ibrar Ahmed | 2019-08-16 14:36:50 | Re: block-level incremental backup |
Previous Message | Konstantin Knizhnik | 2019-08-16 14:12:02 | Re: Global temporary tables |