Re: could not stat promote trigger file leads to shutdown - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: could not stat promote trigger file leads to shutdown
Date
Msg-id 5c794f54-16f1-e4f0-b862-25feda94adf1@2ndquadrant.com
Whole thread Raw
In response to Re: could not stat promote trigger file leads to shutdown  (Fujii Masao <masao.fujii@gmail.com>)
Responses Re: could not stat promote trigger file leads to shutdown  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2019-11-15 03:14, Fujii Masao wrote:
>>> One thought is to try to detect the misconfiguration at postmaster
>>> start --- better to fail at startup than sometime later.  But I'm
>>> not sure how reliably we could do that.
>> I think that we could do something close to the area where
>> RemovePromoteSignalFiles() gets called.  Why not simply checking the
>> path defined by PromoteTriggerFile() at startup time then?  I take it
>> that the only thing we should not complain about is stat() returning
>> ENOENT when looking at the promote file defined.
> promote_trigger_file is declared as PGC_SIGHUP,
> so such check would be necessary even while the standby is running.
> Which can cause the server to fail after the startup.

Let me illustrate a scenario in a more lively way:

Say you want to set up promote_trigger_file to point to a file outside 
of the data directory, maybe because you want to integrate it with some 
external tooling.  So you go into your configuration and set

     promote_trigger_file = '/srv/foobar/trigger'

and reload the server.  Everything is happy.  The fact that the 
directory /srv/foobar/ does not exist at this point is completely ignored.

Now you become root and run

     mkdir /srv/foobar

and, depending circumstances such as root's umask or the permissions of 
/srv, your PostgreSQL server crashes immediately.  That can't be good.

Also imagine the above steps being run by a configuration management system.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



pgsql-hackers by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Role membership and DROP
Next
From: "Kubilay Kaan"
Date:
Subject: Getting Recordset through returning refcursor - second try(firsthas wrong format sorry)