pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: RAJAMOHAN <garajamohan@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Symbolic link breaks for postgresql.auto.conf
Date: Sun, 6 Jun 2021 09:13:59 -0700
Message-ID: <8b0d6567-8c10-90b4-187b-3fd59adfcda8@aklaver.com> (raw)
In-Reply-To: <CAFzdntuKqBv9wYcKVHutJSTypG12z+2dPJZd4d7hnTeyzcuU5w@mail.gmail.com>
References: <CAFzdntuKqBv9wYcKVHutJSTypG12z+2dPJZd4d7hnTeyzcuU5w@mail.gmail.com>

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@aklaver.com





view thread (7+ messages)  latest in thread

Message-ID: <8b0d6567-8c10-90b4-187b-3fd59adfcda8@aklaver.com>
Permalink:  ../8b0d6567-8c10-90b4-187b-3fd59adfcda8@aklaver.com/
Also on:    postgresql.org/message-id/8b0d6567-8c10-90b4-187b-3fd59adfcda8@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, garajamohan@gmail.com
  Subject: Re: Symbolic link breaks for postgresql.auto.conf
  In-Reply-To: <8b0d6567-8c10-90b4-187b-3fd59adfcda8@aklaver.com>
  References: <CAFzdntuKqBv9wYcKVHutJSTypG12z+2dPJZd4d7hnTeyzcuU5w@mail.gmail.com> <8b0d6567-8c10-90b4-187b-3fd59adfcda8@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox