Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6d7547c

Browse files
committed
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 fileis flagged for deletion but not yet actually gone (another in a longlist of reasons why Windows is broken, if you ask me). This seemslikely to explain a lot of irreproducible failures we see in thebuildfarm. 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 pendingdeletion case, we'll see file-not-found and report that after thedeletion completes, and the caller will treat that in an appropriateway.In passing, rejigger the existing retry logic for some other errorcases so that we don't uselessly wait an extra time when we'renot going to retry anymore.Alexander Lakhin (with cosmetic tweaks by me). Back-patch to allsupported branches, since this seems like a pretty safe change andthe problem is definitely real.Discussion:https://postgr.es/m/16161-7a985d2f1bbe8f71@postgresql.org
1 parent91fca4b commit6d7547c

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

‎src/port/open.c

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,14 @@ pgwin32_open(const char *fileName, int fileFlags,...)
111111
{
112112
/*
113113
* Sharing violation or locking error can indicate antivirus, backup
114-
* or similar software that's locking the file.Try again for 30
115-
*seconds beforegiving up.
114+
* or similar software that's locking the file. Wait a bit and try
115+
*again,giving up after 30 seconds.
116116
*/
117117
DWORDerr=GetLastError();
118118

119119
if (err==ERROR_SHARING_VIOLATION||
120120
err==ERROR_LOCK_VIOLATION)
121121
{
122-
pg_usleep(100000);
123-
loops++;
124-
125122
#ifndefFRONTEND
126123
if (loops==50)
127124
ereport(LOG,
@@ -132,7 +129,27 @@ pgwin32_open(const char *fileName, int fileFlags,...)
132129
#endif
133130

134131
if (loops<300)
132+
{
133+
pg_usleep(100000);
134+
loops++;
135+
continue;
136+
}
137+
}
138+
139+
/*
140+
* ERROR_ACCESS_DENIED can be returned if the file is deleted but not
141+
* yet gone (Windows NT status code is STATUS_DELETE_PENDING). Wait a
142+
* bit and try again, giving up after 1 second (since this condition
143+
* should never persist very long).
144+
*/
145+
if (err==ERROR_ACCESS_DENIED)
146+
{
147+
if (loops<10)
148+
{
149+
pg_usleep(100000);
150+
loops++;
135151
continue;
152+
}
136153
}
137154

138155
_dosmaperr(err);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp