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

Commitb1892aa

Browse files
committed
Revert WAL posix_fallocate() patches.
This reverts commit269e780and commit5b571bb.Unfortunately, the initial patch had insufficient performance testing,and resulted in a regression.Per report by Thom Brown.
1 parentbe6fcb6 commitb1892aa

File tree

5 files changed

+36
-60
lines changed

5 files changed

+36
-60
lines changed

‎configure

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19763,8 +19763,7 @@ LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
1976319763

1976419764

1976519765

19766-
19767-
for ac_func in cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat readlink setproctitle setsid sigprocmask symlink sync_file_range towlower utime utimes wcstombs wcstombs_l
19766+
for ac_func in cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat readlink setproctitle setsid sigprocmask symlink sync_file_range towlower utime utimes wcstombs wcstombs_l
1976819767
do
1976919768
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
1977019769
{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5

‎configure.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ PGAC_FUNC_GETTIMEOFDAY_1ARG
12301230
LIBS_including_readline="$LIBS"
12311231
LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'`
12321232

1233-
AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove pollposix_fallocatepstat readlink setproctitle setsid sigprocmask symlink sync_file_range towlower utime utimes wcstombs wcstombs_l])
1233+
AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll pstat readlink setproctitle setsid sigprocmask symlink sync_file_range towlower utime utimes wcstombs wcstombs_l])
12341234

12351235
AC_REPLACE_FUNCS(fseeko)
12361236
case $host_os in

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

Lines changed: 34 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3353,10 +3353,11 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
33533353
{
33543354
charpath[MAXPGPATH];
33553355
chartmppath[MAXPGPATH];
3356+
char*zbuffer;
33563357
XLogSegNoinstalled_segno;
33573358
intmax_advance;
33583359
intfd;
3359-
boolzero_fill= true;
3360+
intnbytes;
33603361

33613362
XLogFilePath(path,ThisTimeLineID,logsegno);
33623363

@@ -3390,6 +3391,16 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
33903391

33913392
unlink(tmppath);
33923393

3394+
/*
3395+
* Allocate a buffer full of zeros. This is done before opening the file
3396+
* so that we don't leak the file descriptor if palloc fails.
3397+
*
3398+
* Note: palloc zbuffer, instead of just using a local char array, to
3399+
* ensure it is reasonably well-aligned; this may save a few cycles
3400+
* transferring data to the kernel.
3401+
*/
3402+
zbuffer= (char*)palloc0(XLOG_BLCKSZ);
3403+
33933404
/* do not use get_sync_bit() here --- want to fsync only at end of fill */
33943405
fd=BasicOpenFile(tmppath,O_RDWR |O_CREAT |O_EXCL |PG_BINARY,
33953406
S_IRUSR |S_IWUSR);
@@ -3398,66 +3409,38 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
33983409
(errcode_for_file_access(),
33993410
errmsg("could not create file \"%s\": %m",tmppath)));
34003411

3401-
#ifdefHAVE_POSIX_FALLOCATE
34023412
/*
3403-
* If posix_fallocate() is available and succeeds, then the file is
3404-
* properly allocated and we don't need to zero-fill it (which is less
3405-
* efficient). In case of an error, fall back to writing zeros, because on
3406-
* some platforms posix_fallocate() is available but will not always
3407-
* succeed in cases where zero-filling will.
3413+
* Zero-fill the file.We have to do this the hard way to ensure that all
3414+
* the file space has really been allocated --- on platforms that allow
3415+
* "holes" in files, just seeking to the end doesn't allocate intermediate
3416+
* space. This way, we know that we have all the space and (after the
3417+
* fsync below) that all the indirect blocks are down on disk.Therefore,
3418+
* fdatasync(2) or O_DSYNC will be sufficient to sync future writes to the
3419+
* log file.
34083420
*/
3409-
if (posix_fallocate(fd,0,XLogSegSize)==0)
3410-
zero_fill= false;
3411-
#endif/* HAVE_POSIX_FALLOCATE */
3412-
3413-
if (zero_fill)
3421+
for (nbytes=0;nbytes<XLogSegSize;nbytes+=XLOG_BLCKSZ)
34143422
{
3415-
/*
3416-
* Allocate a buffer full of zeros. This is done before opening the
3417-
* file so that we don't leak the file descriptor if palloc fails.
3418-
*
3419-
* Note: palloc zbuffer, instead of just using a local char array, to
3420-
* ensure it is reasonably well-aligned; this may save a few cycles
3421-
* transferring data to the kernel.
3422-
*/
3423-
3424-
char*zbuffer= (char*)palloc0(XLOG_BLCKSZ);
3425-
intnbytes;
3426-
3427-
/*
3428-
* Zero-fill the file. We have to do this the hard way to ensure that
3429-
* all the file space has really been allocated --- on platforms that
3430-
* allow "holes" in files, just seeking to the end doesn't allocate
3431-
* intermediate space. This way, we know that we have all the space
3432-
* and (after the fsync below) that all the indirect blocks are down on
3433-
* disk. Therefore, fdatasync(2) or O_DSYNC will be sufficient to sync
3434-
* future writes to the log file.
3435-
*/
3436-
for (nbytes=0;nbytes<XLogSegSize;nbytes+=XLOG_BLCKSZ)
3423+
errno=0;
3424+
if ((int)write(fd,zbuffer,XLOG_BLCKSZ)!= (int)XLOG_BLCKSZ)
34373425
{
3438-
errno=0;
3439-
if ((int)write(fd,zbuffer,XLOG_BLCKSZ)!= (int)XLOG_BLCKSZ)
3440-
{
3441-
intsave_errno=errno;
3426+
intsave_errno=errno;
34423427

3443-
/*
3444-
* If we fail to make the file, delete it to release disk space
3445-
*/
3446-
unlink(tmppath);
3428+
/*
3429+
* If we fail to make the file, delete it to release disk space
3430+
*/
3431+
unlink(tmppath);
34473432

3448-
close(fd);
3433+
close(fd);
34493434

3450-
/* if write didn't set errno, assume no disk space */
3451-
errno=save_errno ?save_errno :ENOSPC;
3435+
/* if write didn't set errno, assume problem is no disk space */
3436+
errno=save_errno ?save_errno :ENOSPC;
34523437

3453-
ereport(ERROR,
3454-
(errcode_for_file_access(),
3455-
errmsg("could not write to file \"%s\": %m",
3456-
tmppath)));
3457-
}
3438+
ereport(ERROR,
3439+
(errcode_for_file_access(),
3440+
errmsg("could not write to file \"%s\": %m",tmppath)));
34583441
}
3459-
pfree(zbuffer);
34603442
}
3443+
pfree(zbuffer);
34613444

34623445
if (pg_fsync(fd)!=0)
34633446
{

‎src/include/pg_config.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,6 @@
369369
/* Define to 1 if you have the `posix_fadvise' function. */
370370
#undef HAVE_POSIX_FADVISE
371371

372-
/* Define to 1 if you have the `posix_fallocate' function. */
373-
#undef HAVE_POSIX_FALLOCATE
374-
375372
/* Define to 1 if you have the POSIX signal interface. */
376373
#undef HAVE_POSIX_SIGNALS
377374

‎src/include/pg_config.h.win32

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@
276276
/* Define to 1 if you have the <poll.h> header file. */
277277
/* #undef HAVE_POLL_H */
278278

279-
/* Define to 1 if you have the `posix_fallocate' function. */
280-
/* #undef HAVE_POSIX_FALLOCATE */
281-
282279
/* Define to 1 if you have the POSIX signal interface. */
283280
/* #undef HAVE_POSIX_SIGNALS */
284281

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp