Re: Weaker shmem interlock w/o postmaster.pid

Noah Misch <noah@leadboat.com>

From: Noah Misch <noah@leadboat.com>
To: David Johnston <polobo@yahoo.com>
Cc: pgsql-hackers@postgresql.org
Date: 2013-09-12T03:25:20Z
Lists: pgsql-hackers
On Wed, Sep 11, 2013 at 07:57:22PM -0700, David Johnston wrote:
> Noah Misch-2 wrote
> > Making PGSharedMemoryCreate() pickier in all branches will greatly
> > diminish
> > the marginal value of preserving postmaster.pid, so I'm fine with dropping
> > the
> > postmaster.pid side of the proposal.
> 
> Its probably still worth a fresh look at the immediate shutdown process to
> see whether the current location where postmaster.pid is removed is
> acceptable.  It may not be necessary to leave it in place always but:
> 
> 1) if there is a section of shared memory that can only be reached/found if
> one knows the pid, and

Similar: one needs a sysv shared memory key to find the segment, and
postmaster.pid records that key.  The chosen key is almost always the same
from run to run, so a new postmaster typically does find the old segment even
without postmaster.pid.

> 2) postmaster.pid is removed before that area is "secured from future
> clobbering"

Clobbering shared memory is not the actual threat here.  We use the shared
memory segment as a witness to the fact that PostgreSQL processes are active
in a data directory.  If we let children of different postmasters operate in
the same directory simultaneously, they can corrupt data.

> then there may be a risk that can still be mitigated by moving its removal
> without having to go to the extreme.  

-- 
Noah Misch
EnterpriseDB                                 http://www.enterprisedb.com


Commits

  1. Probe only 127.0.0.1 when looking for ports on Unix.

  2. Don't write to stdin of a test process that could have already exited.

  3. Test both 0.0.0.0 and 127.0.0.x addresses to find a usable port.

  4. MSYS: Translate REGRESS_SHLIB to a Windows file name.

  5. MSYS: Skip src/test/recovery/t/017_shm.pl.

  6. When Perl "kill(9, ...)" fails, try "pg_ctl kill".

  7. Consistently test for in-use shared memory.

  8. Revert "Consistently test for in-use shared memory."

  9. Silence -Wimplicit-fallthrough in sysv_shmem.c.

  10. Make src/test/recovery/t/017_shm.pl safe for concurrent execution.

  11. Update HINT for pre-existing shared memory block.

  12. Add WL_EXIT_ON_PM_DEATH pseudo-event.

  13. The default values for shared_buffers and max_connections are now 1000

  14. XLOG (and related) changes:

  15. Significant cleanups in SysV IPC handling (shared mem and semaphores).