aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-06-17 16:41:25 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-06-17 16:41:25 +0000
commit07e8b6aabcca3ad9a67681694d955f607e29ce7b (patch)
tree0d7aff9b127566412a2bd3b8606ae501b3c11f91 /src/backend/access/transam/xlog.c
parent8f4e1218458d0d34825d41b50aabadacbdf93697 (diff)
downloadpostgresql-07e8b6aabcca3ad9a67681694d955f607e29ce7b.tar.gz
postgresql-07e8b6aabcca3ad9a67681694d955f607e29ce7b.zip
Don't allow walsender to send WAL data until it's been safely fsync'd on the
master. Otherwise a subsequent crash could cause the master to lose WAL that has already been applied on the slave, resulting in the slave being out of sync and soon corrupt. Per recent discussion and an example from Robert Haas. Fujii Masao
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 5787b3d164c..ab474c35b0d 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.424 2010/06/14 06:04:21 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.425 2010/06/17 16:41:25 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -6803,17 +6803,18 @@ GetInsertRecPtr(void)
}
/*
- * GetWriteRecPtr -- Returns the current write position.
+ * GetFlushRecPtr -- Returns the current flush position, ie, the last WAL
+ * position known to be fsync'd to disk.
*/
XLogRecPtr
-GetWriteRecPtr(void)
+GetFlushRecPtr(void)
{
/* use volatile pointer to prevent code rearrangement */
volatile XLogCtlData *xlogctl = XLogCtl;
XLogRecPtr recptr;
SpinLockAcquire(&xlogctl->info_lck);
- recptr = xlogctl->LogwrtResult.Write;
+ recptr = xlogctl->LogwrtResult.Flush;
SpinLockRelease(&xlogctl->info_lck);
return recptr;