Skip to content

Commit 1a37056

Browse files
committed
Re-enable the old code in xlog.c that tried to use posix_fadvise(), so that
we can get some buildfarm feedback about whether that function is still problematic. (Note that the planned async-preread patch will not really prove anything one way or the other in buildfarm testing, since it will be inactive with default GUC settings.)
1 parent a5d67a0 commit 1a37056

File tree

5 files changed

+30
-27
lines changed

5 files changed

+30
-27
lines changed

configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16238,7 +16238,8 @@ fi
1623816238

1623916239

1624016240

16241-
for ac_func in cbrt dlopen fcvt fdatasync getpeereid getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs
16241+
16242+
for ac_func in cbrt dlopen fcvt fdatasync getpeereid getpeerucred getrlimit memmove poll posix_fadvise pstat readlink setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs
1624216243
do
1624316244
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
1624416245
{ echo "$as_me:$LINENO: checking for $ac_func" >&5

configure.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.584 2009/01/07 10:38:44 petere Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.585 2009/01/11 18:02:17 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1137,7 +1137,7 @@ PGAC_VAR_INT_TIMEZONE
11371137
AC_FUNC_ACCEPT_ARGTYPES
11381138
PGAC_FUNC_GETTIMEOFDAY_1ARG
11391139

1140-
AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getpeereid getpeerucred getrlimit memmove poll pstat readlink setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs])
1140+
AC_CHECK_FUNCS([cbrt dlopen fcvt fdatasync getpeereid getpeerucred getrlimit memmove poll posix_fadvise pstat readlink setproctitle setsid sigprocmask symlink sysconf towlower utime utimes waitpid wcstombs])
11411141

11421142
AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
11431143
AC_CHECK_DECLS(posix_fadvise, [], [], [#include <fcntl.h>])

src/backend/access/transam/xlog.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.326 2009/01/01 17:23:36 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.327 2009/01/11 18:02:17 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -17,6 +17,7 @@
1717
#include <ctype.h>
1818
#include <signal.h>
1919
#include <time.h>
20+
#include <fcntl.h>
2021
#include <sys/stat.h>
2122
#include <sys/time.h>
2223
#include <sys/wait.h>
@@ -2435,30 +2436,18 @@ XLogFileClose(void)
24352436
{
24362437
Assert(openLogFile >= 0);
24372438

2438-
/*
2439-
* posix_fadvise is problematic on many platforms: on older x86 Linux it
2440-
* just dumps core, and there are reports of problems on PPC platforms as
2441-
* well. The following is therefore disabled for the time being. We could
2442-
* consider some kind of configure test to see if it's safe to use, but
2443-
* since we lack hard evidence that there's any useful performance gain to
2444-
* be had, spending time on that seems unprofitable for now.
2445-
*/
2446-
#ifdef NOT_USED
2447-
24482439
/*
24492440
* WAL segment files will not be re-read in normal operation, so we advise
2450-
* OS to release any cached pages. But do not do so if WAL archiving is
2451-
* active, because archiver process could use the cache to read the WAL
2452-
* segment.
2453-
*
2454-
* While O_DIRECT works for O_SYNC, posix_fadvise() works for fsync() and
2455-
* O_SYNC, and some platforms only have posix_fadvise().
2456-
*/
2457-
#if defined(HAVE_DECL_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
2458-
if (!XLogArchivingActive())
2459-
posix_fadvise(openLogFile, 0, 0, POSIX_FADV_DONTNEED);
2441+
* the OS to release any cached pages. But do not do so if WAL archiving
2442+
* is active, because archiver process could use the cache to read the WAL
2443+
* segment. Also, don't bother with it if we are using O_DIRECT, since
2444+
* the kernel is presumably not caching in that case.
2445+
*/
2446+
#if defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
2447+
if (!XLogArchivingActive() &&
2448+
(get_sync_bit(sync_method) & PG_O_DIRECT) == 0)
2449+
(void) posix_fadvise(openLogFile, 0, 0, POSIX_FADV_DONTNEED);
24602450
#endif
2461-
#endif /* NOT_USED */
24622451

24632452
if (close(openLogFile))
24642453
ereport(PANIC,

src/include/pg_config.h.in

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

339+
/* Define to 1 if you have the `posix_fadvise' function. */
340+
#undef HAVE_POSIX_FADVISE
341+
339342
/* Define to 1 if you have the POSIX signal interface. */
340343
#undef HAVE_POSIX_SIGNALS
341344

src/include/pg_config_manual.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* for developers. If you edit any of these, be sure to do a *full*
77
* rebuild (and an initdb if noted).
88
*
9-
* $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.35 2008/07/12 02:28:43 tgl Exp $
9+
* $PostgreSQL: pgsql/src/include/pg_config_manual.h,v 1.36 2009/01/11 18:02:17 tgl Exp $
1010
*------------------------------------------------------------------------
1111
*/
1212

@@ -112,7 +112,7 @@
112112
#define ALIGNOF_BUFFER 32
113113

114114
/*
115-
* Disable UNIX sockets for those operating system.
115+
* Disable UNIX sockets for certain operating systems.
116116
*/
117117
#if defined(WIN32)
118118
#undef HAVE_UNIX_SOCKETS
@@ -125,6 +125,16 @@
125125
#define HAVE_WORKING_LINK 1
126126
#endif
127127

128+
/*
129+
* USE_POSIX_FADVISE controls whether Postgres will attempt to use the
130+
* posix_fadvise() kernel call. Usually the automatic configure tests are
131+
* sufficient, but some older Linux distributions had broken versions of
132+
* posix_fadvise(). If necessary you can remove the #define here.
133+
*/
134+
#if HAVE_DECL_POSIX_FADVISE && defined(HAVE_POSIX_FADVISE)
135+
#define USE_POSIX_FADVISE
136+
#endif
137+
128138
/*
129139
* This is the default directory in which AF_UNIX socket files are
130140
* placed. Caution: changing this risks breaking your existing client

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy