On 6/6/21 9:00 AM, RAJAMOHAN wrote:
Hello all,
Can someone explain how *postgresql.auto.conf *file contents gets
updated, when running an alter system statement followed by pg_reload_conf?
I am trying to keep a symbolic link for the
*postgresql.auto.conf* outside the data directory. The link gets created
but whenever I issue an alter system statement it gets broken.
The main reason for this symbolic link creation is to retain the
parameter values associated with this cluster, because we will be
copying the entire data directory from another server to this server
from time to time for testing purposes.
And no issues with other files such as hba and postgresql.conf.
*Operating System: Ubuntu 18.04.1 LTS
*
*Postgresql : 12.7*
Step1:
Created symbolic links and i am inside data directory
lrwxrwxrwx 1 postgres postgres 41 Jun 3 05:12 postgresql.conf ->
/etc/postgresql/12/test1/postgresql.conf
lrwxrwxrwx 1 postgres postgres 37 Jun 3 05:12 pg_hba.conf ->
/etc/postgresql/12/test1/pg_hba.conf
lrwxrwxrwx 1 postgres postgres 46 Jun 6 15:19 postgresql.auto.conf ->
/etc/postgresql/12/test1/postgresql.auto.conf
Step2:
alter system set checkpoint_timeout='2min';select pg_reload_conf();
ALTER SYSTEM
pg_reload_conf
----------------
t
(1 row)
Step3:
Symbolic link got broken
lrwxrwxrwx 1 postgres postgres 41 Jun 3 05:12 postgresql.conf ->
/etc/postgresql/12/test1/postgresql.conf
lrwxrwxrwx 1 postgres postgres 37 Jun 3 05:12 pg_hba.conf ->
/etc/postgresql/12/test1/pg_hba.conf
lrwxrwxrwx 1 postgres postgres 46 Jun 6 15:19 postgresql.auto.conf
Have to believe it is due to:
~/src/backend/utils/misc/guc.c
/*
* Execute ALTER SYSTEM statement.
*
* Read the old PG_AUTOCONF_FILENAME file, merge in the new variable value,
* and write out an updated file. If the command is ALTER SYSTEM RESET
ALL,
* we can skip reading the old file and just write an empty file.
*
* An LWLock is used to serialize updates of the configuration file.
*
* In case of an error, we leave the original automatic
* configuration file (PG_AUTOCONF_FILENAME) intact.
*/
In particular:
/*
* To ensure crash safety, first write the new file data to a
temp file,
* then atomically rename it into place.
*
* If there is a temp file left over due to a previous crash,
it's okay to
* truncate and reuse it.
*/
Thanks & Regards,
Rajamohan.J
--
Adrian Klaver
adrian.klaver@xxxxxxxxxxx