aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlogutils.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-03-31 23:32:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-03-31 23:32:07 +0000
commita8b8f4db23cff16af50a2b960cb8d20d39b761cf (patch)
tree224f8cb0da7e2e17ccfd7b8a030db1664acd46c1 /src/backend/access/transam/xlogutils.c
parent89395bfa6f2fafccec10be377fcf759030910654 (diff)
downloadpostgresql-a8b8f4db23cff16af50a2b960cb8d20d39b761cf.tar.gz
postgresql-a8b8f4db23cff16af50a2b960cb8d20d39b761cf.zip
Clean up WAL/buffer interactions as per my recent proposal. Get rid of the
misleadingly-named WriteBuffer routine, and instead require routines that change buffer pages to call MarkBufferDirty (which does exactly what it says). We also require that they do so before calling XLogInsert; this takes care of the synchronization requirement documented in SyncOneBuffer. Note that because bufmgr takes the buffer content lock (in shared mode) while writing out any buffer, it doesn't matter whether MarkBufferDirty is executed before the buffer content change is complete, so long as the content change is completed before releasing exclusive lock on the buffer. So it's OK to set the dirtybit before we fill in the LSN. This eliminates the former kluge of needing to set the dirtybit in LockBuffer. Aside from making the code more transparent, we can also add some new debugging assertions, in particular that the caller of MarkBufferDirty must hold the buffer content lock, not merely a pin.
Diffstat (limited to 'src/backend/access/transam/xlogutils.c')
-rw-r--r--src/backend/access/transam/xlogutils.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c
index fb771fe2fd1..1ab4095350a 100644
--- a/src/backend/access/transam/xlogutils.c
+++ b/src/backend/access/transam/xlogutils.c
@@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.42 2006/03/29 21:17:38 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlogutils.c,v 1.43 2006/03/31 23:32:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,9 +30,9 @@
*
* This is functionally comparable to ReadBuffer followed by
* LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE): you get back a pinned
- * and locked buffer. (The lock is not really necessary, since we
- * expect that this is only done during single-process XLOG replay,
- * but in some places it simplifies sharing code with the non-XLOG case.)
+ * and locked buffer. (Getting the lock is not really necessary, since we
+ * expect that this is only used during single-process XLOG replay, but
+ * some subroutines such as MarkBufferDirty will complain if we don't.)
*
* If "init" is true then the caller intends to rewrite the page fully
* using the info in the XLOG record. In this case we will extend the
@@ -74,7 +74,7 @@ XLogReadBuffer(Relation reln, BlockNumber blkno, bool init)
while (blkno >= lastblock)
{
if (buffer != InvalidBuffer)
- ReleaseBuffer(buffer); /* must be WriteBuffer()? */
+ ReleaseBuffer(buffer);
buffer = ReadBuffer(reln, P_NEW);
lastblock++;
}