Re: Unexpected "shared memory block is still in use"
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Noah Misch <noah@leadboat.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2019-05-10T20:46:40Z
Lists: pgsql-hackers
I wrote: > Will go fix/backpatch in a minute. Done now, but while thinking more about the issue, I had an idea: why is it that we base the shmem key on the postmaster's port number, and not on the data directory's inode number? Using the port number not only increases the risk of collisions (though admittedly only in testing situations), but it *decreases* our ability to detect real conflicts. Consider case where DBA wants to change the installation's port number, and he edits postgresql.conf, but then uses "kill -9 && rm postmaster.pid" rather than some saner way of stopping the old postmaster. When he starts the new one, it won't detect any remaining children of the old postmaster because it'll be looking in the wrong range of shmem keys. It seems like something tied to the data directory's identity would be much more trustworthy. I think the reason for doing it this way originally was to allow one to identify which shmem segment is which in "ipcs -m" output. But that was back when having to clean up shmem segments manually was still a common task. It's been a long time since I can remember needing to figure out which was which. regards, tom lane
Commits
-
Use data directory inode number, not port, to select SysV resource keys.
- 7de19fbc0b1a 13.0 landed
-
Cope with EINVAL and EIDRM shmat() failures in PGSharedMemoryAttach.
- b1cde67a4f94 9.4.23 landed
- a73c8caea46c 9.6.14 landed
- 91a05390c33c 9.5.18 landed
- 803f90ab795b 11.4 landed
- 610747d86e46 12.0 landed
- 3dcf45af560e 10.9 landed
-
Consistently test for in-use shared memory.
- c098509927f9 12.0 cited