pgsql: On Windows, wait a little to see if ERROR_ACCESS_DENIED goes awa

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: On Windows, wait a little to see if ERROR_ACCESS_DENIED goes awa
Date: 2019-12-16 20:11:16
Message-ID: E1igwi4-0007yP-Mb@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On Windows, wait a little to see if ERROR_ACCESS_DENIED goes away.

Attempting to open a file fails with ERROR_ACCESS_DENIED if the file
is flagged for deletion but not yet actually gone (another in a long
list of reasons why Windows is broken, if you ask me). This seems
likely to explain a lot of irreproducible failures we see in the
buildfarm. This state generally persists for only a millisecond or so,
so just wait a bit and retry. If it's a real permissions problem,
we'll eventually give up and report it as such. If it's the pending
deletion case, we'll see file-not-found and report that after the
deletion completes, and the caller will treat that in an appropriate
way.

In passing, rejigger the existing retry logic for some other error
cases so that we don't uselessly wait an extra time when we're
not going to retry anymore.

Alexander Lakhin (with cosmetic tweaks by me). Back-patch to all
supported branches, since this seems like a pretty safe change and
the problem is definitely real.

Discussion: https://postgr.es/m/16161-7a985d2f1bbe8f71@postgresql.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6d7547c219adf2436323cdbd4bebc5e872d53546

Modified Files
--------------
src/port/open.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Geoghegan 2019-12-17 01:12:43 pgsql: Update nbtree README's "Scans during Recovery".
Previous Message Alvaro Herrera 2019-12-16 17:24:37 pgsql: Demote variable from global to local