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

Commit5b571bb

Browse files
committed
Handle posix_fallocate() errors.
On some platforms, posix_fallocate() is available but may still returnEINVAL if the underlying filesystem does not support it. So, in caseof an error, fall through to the alternate implementation that justwrites zeros.Per buildfarm failure and analysis by Tom Lane.
1 parent43c3aab commit5b571bb

File tree

1 file changed

+12
-18
lines changed
  • src/backend/access/transam

1 file changed

+12
-18
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,6 +2259,7 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
22592259
XLogSegNoinstalled_segno;
22602260
intmax_advance;
22612261
intfd;
2262+
boolzero_fill= true;
22622263

22632264
XLogFilePath(path,ThisTimeLineID,logsegno);
22642265

@@ -2301,24 +2302,18 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
23012302
errmsg("could not create file \"%s\": %m",tmppath)));
23022303

23032304
#ifdefHAVE_POSIX_FALLOCATE
2304-
{
2305-
errno=posix_fallocate(fd,0,XLogSegSize);
2306-
2307-
if (errno)
2308-
{
2309-
interrno_saved=errno;
2310-
2311-
close(fd);
2312-
unlink(tmppath);
2313-
errno=errno_saved;
2305+
/*
2306+
* Ifposix_fallocate() is available and succeeds, then the file is
2307+
* properly allocated and we don't need to zero-fill it (which is less
2308+
* efficient). In case of an error, fall back to writing zeros, because on
2309+
* some platforms posix_fallocate() is available but will not always
2310+
* succeed in cases where zero-filling will.
2311+
*/
2312+
if (posix_fallocate(fd,0,XLogSegSize)==0)
2313+
zero_fill= false;
2314+
#endif/* HAVE_POSIX_FALLOCATE */
23142315

2315-
ereport(ERROR,
2316-
(errcode_for_file_access(),
2317-
errmsg("could not allocate space for file \"%s\" using posix_fallocate: %m",
2318-
tmppath)));
2319-
}
2320-
}
2321-
#else/* !HAVE_POSIX_FALLOCATE */
2316+
if (zero_fill)
23222317
{
23232318
/*
23242319
* Allocate a buffer full of zeros. This is done before opening the
@@ -2366,7 +2361,6 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
23662361
}
23672362
pfree(zbuffer);
23682363
}
2369-
#endif/* HAVE_POSIX_FALLOCATE */
23702364

23712365
if (pg_fsync(fd)!=0)
23722366
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp