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

Commit3d39244

Browse files
committed
Retry opening new segments in pg_xlogdump --folllow
There is a small window between when the server closes out the existingsegment and the new one is created. Put a loop around the open call inthis case to make sure we wait for the new file to actually appear.
1 parentfd321a1 commit3d39244

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

‎src/bin/pg_xlogdump/pg_xlogdump.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ XLogDumpXLogRead(const char *directory, TimeLineID timeline_id,
249249
if (sendFile<0|| !XLByteInSeg(recptr,sendSegNo))
250250
{
251251
charfname[MAXFNAMELEN];
252+
inttries;
252253

253254
/* Switch to another logfile segment */
254255
if (sendFile >=0)
@@ -258,7 +259,30 @@ XLogDumpXLogRead(const char *directory, TimeLineID timeline_id,
258259

259260
XLogFileName(fname,timeline_id,sendSegNo);
260261

261-
sendFile=fuzzy_open_file(directory,fname);
262+
/*
263+
* In follow mode there is a short period of time after the
264+
* server has written the end of the previous file before the
265+
* new file is available. So we loop for 5 seconds looking
266+
* for the file to appear before giving up.
267+
*/
268+
for (tries=0;tries<10;tries++)
269+
{
270+
sendFile=fuzzy_open_file(directory,fname);
271+
if (sendFile >=0)
272+
break;
273+
if (errno==ENOENT)
274+
{
275+
intsave_errno=errno;
276+
277+
/* File not there yet, try again */
278+
pg_usleep(500*1000);
279+
280+
errno=save_errno;
281+
continue;
282+
}
283+
/* Any other error, fall through and fail */
284+
break;
285+
}
262286

263287
if (sendFile<0)
264288
fatal_error("could not find file \"%s\": %s",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp