aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-01-11 18:02:17 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-01-11 18:02:17 +0000
commit1a37056a74e273085c39bb88cba48797695c067e (patch)
treee2ea1b44aaed4c75035b887a2de06ed4901f1374 /src/backend/access/transam/xlog.c
parenta5d67a0a050a9d32c351183992c3f08631735c37 (diff)
downloadpostgresql-1a37056a74e273085c39bb88cba48797695c067e.tar.gz
postgresql-1a37056a74e273085c39bb88cba48797695c067e.zip
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.)
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index daea9fafdfb..9a2b3308b1e 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.326 2009/01/01 17:23:36 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.327 2009/01/11 18:02:17 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,6 +17,7 @@
#include <ctype.h>
#include <signal.h>
#include <time.h>
+#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/wait.h>
@@ -2436,29 +2437,17 @@ XLogFileClose(void)
Assert(openLogFile >= 0);
/*
- * posix_fadvise is problematic on many platforms: on older x86 Linux it
- * just dumps core, and there are reports of problems on PPC platforms as
- * well. The following is therefore disabled for the time being. We could
- * consider some kind of configure test to see if it's safe to use, but
- * since we lack hard evidence that there's any useful performance gain to
- * be had, spending time on that seems unprofitable for now.
- */
-#ifdef NOT_USED
-
- /*
* WAL segment files will not be re-read in normal operation, so we advise
- * OS to release any cached pages. But do not do so if WAL archiving is
- * active, because archiver process could use the cache to read the WAL
- * segment.
- *
- * While O_DIRECT works for O_SYNC, posix_fadvise() works for fsync() and
- * O_SYNC, and some platforms only have posix_fadvise().
- */
-#if defined(HAVE_DECL_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
- if (!XLogArchivingActive())
- posix_fadvise(openLogFile, 0, 0, POSIX_FADV_DONTNEED);
+ * the OS to release any cached pages. But do not do so if WAL archiving
+ * is active, because archiver process could use the cache to read the WAL
+ * segment. Also, don't bother with it if we are using O_DIRECT, since
+ * the kernel is presumably not caching in that case.
+ */
+#if defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
+ if (!XLogArchivingActive() &&
+ (get_sync_bit(sync_method) & PG_O_DIRECT) == 0)
+ (void) posix_fadvise(openLogFile, 0, 0, POSIX_FADV_DONTNEED);
#endif
-#endif /* NOT_USED */
if (close(openLogFile))
ereport(PANIC,