pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Postgres hackers <pgsql-hackers@postgresql.org>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Subject: Re: pgsql: Fix failure to check for open() or fsync() failures.
Date: Thu, 27 Dec 2018 11:10:39 +0900
Message-ID: <20181227021039.GI2106@paquier.xyz> (raw)
In-Reply-To: <32282.1545874522@sss.pgh.pa.us>
References: <E1gcGPf-0000Ih-1f@gemulon.postgresql.org>
	<20181226224351.GA2106@paquier.xyz>
	<26009.1545864936@sss.pgh.pa.us>
	<20181227010918.GC2106@paquier.xyz>
	<32282.1545874522@sss.pgh.pa.us>

On Wed, Dec 26, 2018 at 08:35:22PM -0500, Tom Lane wrote:
> Oh, I see.  Yeah, if we're ignoring errors anyway, the stat calls
> seem redundant.

For this one, I think that we could simplify as attached (this causes
open() to fail additionally because of the sync flags, but that's not
really worth worrying).  Thoughts?
--
Michael

Attachments:

recovery-signal-simplify.patch (text/x-diff, 1.5K) download diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 5729867879..34ebf6716e 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5307,6 +5307,7 @@ static void readRecoverySignalFile(void) { struct stat stat_buf; + int fd; if (IsBootstrapProcessingMode()) return; @@ -5333,30 +5334,20 @@ readRecoverySignalFile(void) * If present, standby signal file takes precedence. If neither is present * then we won't enter archive recovery. */ - if (stat(STANDBY_SIGNAL_FILE, &stat_buf) == 0) + if ((fd = BasicOpenFilePerm(STANDBY_SIGNAL_FILE, + O_RDWR | PG_BINARY | get_sync_bit(sync_method), + S_IRUSR | S_IWUSR)) >= 0) { - int fd; - - fd = BasicOpenFilePerm(STANDBY_SIGNAL_FILE, O_RDWR | PG_BINARY | get_sync_bit(sync_method), - S_IRUSR | S_IWUSR); - if (fd >= 0) - { - (void) pg_fsync(fd); - close(fd); - } + (void) pg_fsync(fd); + close(fd); standby_signal_file_found = true; } - else if (stat(RECOVERY_SIGNAL_FILE, &stat_buf) == 0) + else if ((fd = BasicOpenFilePerm(RECOVERY_SIGNAL_FILE, + O_RDWR | PG_BINARY | get_sync_bit(sync_method), + S_IRUSR | S_IWUSR)) >= 0) { - int fd; - - fd = BasicOpenFilePerm(RECOVERY_SIGNAL_FILE, O_RDWR | PG_BINARY | get_sync_bit(sync_method), - S_IRUSR | S_IWUSR); - if (fd >= 0) - { - (void) pg_fsync(fd); - close(fd); - } + (void) pg_fsync(fd); + close(fd); recovery_signal_file_found = true; }
signature.asc (application/pgp-signature, 832B) download

view thread (7+ messages)  latest in thread

Message-ID: <20181227021039.GI2106@paquier.xyz>
Permalink:  ../20181227021039.GI2106@paquier.xyz/
Also on:    postgresql.org/message-id/20181227021039.GI2106@paquier.xyz

 ·  · 

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-committers@postgresql.org
  Cc: michael@paquier.xyz, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org, peter.eisentraut@2ndquadrant.com
  Subject: Re: pgsql: Fix failure to check for open() or fsync() failures.
  In-Reply-To: <20181227021039.GI2106@paquier.xyz>
  References: <E1gcGPf-0000Ih-1f@gemulon.postgresql.org> <20181226224351.GA2106@paquier.xyz> <26009.1545864936@sss.pgh.pa.us> <20181227010918.GC2106@paquier.xyz> <32282.1545874522@sss.pgh.pa.us> <20181227021039.GI2106@paquier.xyz>

* 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