You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Use data directory inode number, not port, to select SysV resource keys.
This approach provides a much tighter binding between a data directoryand the associated SysV shared memory block (and SysV or named-POSIXsemaphores, if we're using those). Key collisions are still possible,but only between data directories stored on different filesystems,so the situation should be negligible in practice. More importantly,restarting the postmaster with a different port number no longerrisks failing to identify a relevant shared memory block, even whenpostmaster.pid has been removed. A standalone backend is likewisemuch more certain to detect conflicting leftover backends.(In the longer term, we might now think about deprecating the port asa cluster-wide value, so that one postmaster could support socketswith varying port numbers. But that's for another day.)The hazards fixed here apply only on Unix systems; our Windows codepaths already use identifiers derived from the data directory pathname rather than the port.src/test/recovery/t/017_shm.pl, which intends to test key-collisioncases, has been substantially rewritten since it can no longer usetwo postmasters with identical port numbers to trigger the case.Instead, use Perl's IPC::SharedMem module to create a conflictingshmem segment directly. The test script will be skipped if thatmodule is not available. (This means that some older buildfarmmembers won't run it, but I don't think that that results in anymeaningful coverage loss.)Patch by me; thanks to Noah Misch and Peter Eisentraut for discussionand review.Discussion:https://postgr.es/m/16908.1557521200@sss.pgh.pa.us