Re: PG in container w/ pid namespace is init, process exits cause restart - Mailing list pgsql-hackers

From Greg Stark
Subject Re: PG in container w/ pid namespace is init, process exits cause restart
Date
Msg-id CAM-w4HO90N1PLSw=2k+8L_RWsgoUGREkDsm+qvg8qqNYyvtTWA@mail.gmail.com
Whole thread Raw
In response to Re: PG in container w/ pid namespace is init, process exits cause restart  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: PG in container w/ pid namespace is init, process exits cause restart
Re: PG in container w/ pid namespace is init, process exits cause restart
List pgsql-hackers
On Mon, 3 May 2021 at 15:44, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>
> Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> > I also heard a story where things ran into trouble (I didn't get the
> > whole story of *what* was the problem with that) because the datadir is /.
>
> BTW, as far as that goes, I think the general recommendation is that
> the datadir shouldn't be a mount point, because bad things happen if
> you mount or unmount the drive while the postmaster is up.  I could
> see enforcing that, if we could find a reasonably platform-independent
> way to do it.

I don't think the problem is unmounting -- on BSD you have to try
really hard to unmount filesystems that have files open on them and
afaik you can't do it on Linux at all (which I still claim is the
original sin that led to the fsync issues).

The problem was mounting filesystems if it happened late -- ie. After
Postgres had started up. It was exacerbated by some startup scripts
that would automatically run initdb if there was nothing present.

Offhand I don't actually see anything special about the Postgres
directory root being the mountpoint though. There's nothing stopping
someone from mounting on top of some parent directory other than it
being slightly harder to imagine someone creating the whole directory
tree up from the postgres root rather than just running initdb.

Fwiw, I have a suspicion that the right check for being init is
whether `pid == ppid`.

-- 
greg



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Incorrect snapshots while promoting hot standby node when 2PC is used
Next
From: Tom Lane
Date:
Subject: Re: PG in container w/ pid namespace is init, process exits cause restart