Re: RFC: Add 'taint' field to pg_control. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: RFC: Add 'taint' field to pg_control.
Date
Msg-id 1576.1520483677@sss.pgh.pa.us
Whole thread Raw
In response to Re: RFC: Add 'taint' field to pg_control.  (Craig Ringer <craig@2ndquadrant.com>)
Responses Re: RFC: Add 'taint' field to pg_control.  (Craig Ringer <craig@2ndquadrant.com>)
Re: RFC: Add 'taint' field to pg_control.  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Craig Ringer <craig@2ndquadrant.com> writes:
> As I understand it, because we allow multiple Pg instances on a system, we
> identify the small sysv shmem segment we use by the postmaster's pid. If
> you remove the DirLockFile (postmaster.pid) you remove the interlock
> against starting a new postmaster. It'll think it's a new independent
> instance on the same host, make a new shmem segment and go merrily on its
> way mangling data horribly.

Yeah.  If we realized that the old shmem segment was associated with this
data directory, we could check for processes still attached to it ... but
the lock file is exactly where that association is kept.

> It'd be nice if the OS offered us some support here. Something like opening
> a lockfile in exclusive lock mode, then inheriting the FD and lock on all
> children, with each child inheriting the lock. So the exclusive lock
> wouldn't get released until all FDs associated with it are released. But
> AFAIK nothing like that is present, let alone portable.

I've wondered about that too.  An inheritable lock on the data directory
itself would be ideal, but that doesn't exist anywhere AFAIK.  We could
imagine taking a BSD-style-flock(2) lock on some lock file, on systems that
have that; but not all do, so it couldn't be our only protection.  Another
problem is that since it'd have to be an ordinary file, there'd still be a
risk of cowboy DBAs removing the lock file.  Maybe we could use pg_control
as the lock file?

            regards, tom lane


pgsql-hackers by date:

Previous
From: Edmund Horner
Date:
Subject: Re: PATCH: psql tab completion for SELECT
Next
From: Ashutosh Bapat
Date:
Subject: Re: [HACKERS] Another oddity in handling of WCO constraints in postgres_fdw