From 07e8b6aabcca3ad9a67681694d955f607e29ce7b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 17 Jun 2010 16:41:25 +0000 Subject: 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 --- src/backend/access/transam/xlog.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/backend/access/transam/xlog.c') 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; -- cgit v1.2.3