diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-05-31 03:48:10 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-05-31 03:48:10 +0000 |
commit | 9b178555fc1f5087c120ff4d26380395bc655a03 (patch) | |
tree | 3578c76707795c2b25910ea42b36928eb6d4d742 /src/backend/access/transam/clog.c | |
parent | f024086db30f26905e4c877a6795c1ab95f4ab12 (diff) | |
download | postgresql-9b178555fc1f5087c120ff4d26380395bc655a03.tar.gz postgresql-9b178555fc1f5087c120ff4d26380395bc655a03.zip |
Per previous discussions, get rid of use of sync(2) in favor of
explicitly fsync'ing every (non-temp) file we have written since the
last checkpoint. In the vast majority of cases, the burden of the
fsyncs should fall on the bgwriter process not on backends. (To this
end, we assume that an fsync issued by the bgwriter will force out
blocks written to the same file by other processes using other file
descriptors. Anyone have a problem with that?) This makes the world
safe for WIN32, which ain't even got sync(2), and really makes the world
safe for Unixen as well, because sync(2) never had the semantics we need:
it offers no way to wait for the requested I/O to finish.
Along the way, fix a bug I recently introduced in xlog recovery:
file truncation replay failed to clear bufmgr buffers for the dropped
blocks, which could result in 'PANIC: heap_delete_redo: no block'
later on in xlog replay.
Diffstat (limited to 'src/backend/access/transam/clog.c')
-rw-r--r-- | src/backend/access/transam/clog.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c index 88e1f1256ad..97f887d0a06 100644 --- a/src/backend/access/transam/clog.c +++ b/src/backend/access/transam/clog.c @@ -13,7 +13,7 @@ * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.19 2003/11/29 19:51:40 pgsql Exp $ + * $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.20 2004/05/31 03:47:54 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -97,7 +97,7 @@ TransactionIdSetStatus(TransactionId xid, XidStatus status) Assert(status == TRANSACTION_STATUS_COMMITTED || status == TRANSACTION_STATUS_ABORTED); - LWLockAcquire(ClogCtl->locks->ControlLock, LW_EXCLUSIVE); + LWLockAcquire(ClogCtl->ControlLock, LW_EXCLUSIVE); byteptr = SimpleLruReadPage(ClogCtl, pageno, xid, true); byteptr += byteno; @@ -110,7 +110,7 @@ TransactionIdSetStatus(TransactionId xid, XidStatus status) /* ...->page_status[slotno] = CLOG_PAGE_DIRTY; already done */ - LWLockRelease(ClogCtl->locks->ControlLock); + LWLockRelease(ClogCtl->ControlLock); } /* @@ -128,14 +128,14 @@ TransactionIdGetStatus(TransactionId xid) char *byteptr; XidStatus status; - LWLockAcquire(ClogCtl->locks->ControlLock, LW_EXCLUSIVE); + LWLockAcquire(ClogCtl->ControlLock, LW_EXCLUSIVE); byteptr = SimpleLruReadPage(ClogCtl, pageno, xid, false); byteptr += byteno; status = (*byteptr >> bshift) & CLOG_XACT_BITMASK; - LWLockRelease(ClogCtl->locks->ControlLock); + LWLockRelease(ClogCtl->ControlLock); return status; } @@ -169,16 +169,16 @@ BootStrapCLOG(void) { int slotno; - LWLockAcquire(ClogCtl->locks->ControlLock, LW_EXCLUSIVE); + LWLockAcquire(ClogCtl->ControlLock, LW_EXCLUSIVE); /* Create and zero the first page of the commit log */ slotno = ZeroCLOGPage(0, false); /* Make sure it's written out */ - SimpleLruWritePage(ClogCtl, slotno); + SimpleLruWritePage(ClogCtl, slotno, NULL); /* Assert(ClogCtl->page_status[slotno] == CLOG_PAGE_CLEAN); */ - LWLockRelease(ClogCtl->locks->ControlLock); + LWLockRelease(ClogCtl->ControlLock); } /* @@ -256,12 +256,12 @@ ExtendCLOG(TransactionId newestXact) pageno = TransactionIdToPage(newestXact); - LWLockAcquire(ClogCtl->locks->ControlLock, LW_EXCLUSIVE); + LWLockAcquire(ClogCtl->ControlLock, LW_EXCLUSIVE); /* Zero the page and make an XLOG entry about it */ ZeroCLOGPage(pageno, true); - LWLockRelease(ClogCtl->locks->ControlLock); + LWLockRelease(ClogCtl->ControlLock); } @@ -351,13 +351,13 @@ clog_redo(XLogRecPtr lsn, XLogRecord *record) memcpy(&pageno, XLogRecGetData(record), sizeof(int)); - LWLockAcquire(ClogCtl->locks->ControlLock, LW_EXCLUSIVE); + LWLockAcquire(ClogCtl->ControlLock, LW_EXCLUSIVE); slotno = ZeroCLOGPage(pageno, false); - SimpleLruWritePage(ClogCtl, slotno); + SimpleLruWritePage(ClogCtl, slotno, NULL); /* Assert(ClogCtl->page_status[slotno] == SLRU_PAGE_CLEAN); */ - LWLockRelease(ClogCtl->locks->ControlLock); + LWLockRelease(ClogCtl->ControlLock); } } |