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 

       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 data specified
           by the write() for that position until such byte positions are again 

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



Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:

Reply via email to