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

Commit4bff35c

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 parent3c97a7c commit4bff35c

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

‎contrib/pg_xlogdump/pg_xlogdump.c

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ XLogDumpXLogRead(const char *directory, TimeLineID timeline_id,
231231
if (sendFile<0|| !XLByteInSeg(recptr,sendSegNo))
232232
{
233233
charfname[MAXFNAMELEN];
234+
inttries;
234235

235236
/* Switch to another logfile segment */
236237
if (sendFile >=0)
@@ -240,7 +241,30 @@ XLogDumpXLogRead(const char *directory, TimeLineID timeline_id,
240241

241242
XLogFileName(fname,timeline_id,sendSegNo);
242243

243-
sendFile=fuzzy_open_file(directory,fname);
244+
/*
245+
* In follow mode there is a short period of time after the
246+
* server has written the end of the previous file before the
247+
* new file is available. So we loop for 5 seconds looking
248+
* for the file to appear before giving up.
249+
*/
250+
for (tries=0;tries<10;tries++)
251+
{
252+
sendFile=fuzzy_open_file(directory,fname);
253+
if (sendFile >=0)
254+
break;
255+
if (errno==ENOENT)
256+
{
257+
intsave_errno=errno;
258+
259+
/* File not there yet, try again */
260+
pg_usleep(500*1000);
261+
262+
errno=save_errno;
263+
continue;
264+
}
265+
/* Any other error, fall through and fail */
266+
break;
267+
}
244268

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp