Re: pg_ctl promote wait - Mailing list pgsql-hackers

From Andres Freund
Subject Re: pg_ctl promote wait
Date
Msg-id 20160219191534.yunti6ppenvqpqms@alap3.anarazel.de
Whole thread Raw
In response to Re: pg_ctl promote wait  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
On 2016-02-19 13:48:52 -0500, Peter Eisentraut wrote:
> Is it safe to read pg_control externally without a lock?  pg_controldata
> will just report a CRC error and proceed, and if you're not sure you can
> just run it again.  But if a promotion fails every so often because of
> concurrent pg_control writes, that would make this feature annoying.

Yes, the OS should give sufficient guarantees here:
      If write() is interrupted by a signal before it writes any data, it shall return −1 with errno set to [EINTR].
      If write() is interrupted by a signal after it successfully writes some data, it shall return the number of bytes
written.
      If the value of nbyte is greater than {SSIZE_MAX}, the result is implementation-defined.
      After a write() to a regular file has successfully returned:
       *  Any successful read() from each byte position in the file that was modified by that write shall return the
dataspecified          by the write() for that position until such byte positions are again modified.
 

We currently assume that all "small" writes succeed in one go (and throw
errors if not). Thus the guarantees by read/write are sufficient.

Regards,

Andres



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: pg_ctl promote wait
Next
From: Andres Freund
Date:
Subject: Re: pg_ctl promote wait