Re: Intermittent pg_ctl failures on Windows

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: r.zharkov@postgrespro.ru, Badrul Chowdhury <bachow@microsoft.com>, pgsql-hackers@lists.postgresql.org
Date: 2019-07-18T05:38:34Z
Lists: pgsql-hackers
On Wed, Jul 17, 2019 at 09:51:48AM -0400, Tom Lane wrote:
> r.zharkov@postgrespro.ru writes:
>> On Windows systems we cannot handle ERROR_DELETE_PENDING because 
>> GetLastError() returns ERROR_ACCESS_DENIED instead.
>> So we rename the lock files before delete them.
> 
> This seems improbably broken/stupid.  Also, I've not seen any buildfarm
> failures that would match this; it's always pg_ctl complaining not the
> postmaster.

Oh, it is.  A lot.  And this has been discussed a couple of times
across multiple threads on -bugs and/or -hackers.  I think that
Windows just lacks a way to detect reliably if a file is pending for
deletion or not, and there is no way that we are going to enforce
blindly a ERROR_DELETE_PENDING when we see EACCES.  One code path
which is impacted by that is our wrapper for stat() for the win32
port...  For now I'd rather believe that what the OS tells us is true,
in which case here it is plain wrong, but well. 
--
Michael

Commits

  1. Allow concurrent-safe open() and fopen() in frontend code for Windows

  2. Change pg_ctl to detect server-ready by watching status in postmaster.pid.