mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Change order of operations during XLogFlush so that we try to include
in our write/flush operation any WAL entries that got queued while we were waiting to get the WALWriteLock. This improves throughput when transactions are small enough that several can be committed per WAL write (ie, per disk revolution).
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.107 2002/09/26 22:58:33 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.108 2002/10/07 17:04:30 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1252,7 +1252,12 @@ XLogFlush(XLogRecPtr record)
|
||||
/* done already? */
|
||||
if (!XLByteLE(record, LogwrtResult.Flush))
|
||||
{
|
||||
/* if something was added to log cache then try to flush this too */
|
||||
/* now wait for the write lock */
|
||||
LWLockAcquire(WALWriteLock, LW_EXCLUSIVE);
|
||||
LogwrtResult = XLogCtl->Write.LogwrtResult;
|
||||
if (!XLByteLE(record, LogwrtResult.Flush))
|
||||
{
|
||||
/* try to write/flush later additions to XLOG as well */
|
||||
if (LWLockConditionalAcquire(WALInsertLock, LW_EXCLUSIVE))
|
||||
{
|
||||
XLogCtlInsert *Insert = &XLogCtl->Insert;
|
||||
@ -1266,14 +1271,14 @@ XLogFlush(XLogRecPtr record)
|
||||
WriteRqstPtr.xrecoff -= freespace;
|
||||
}
|
||||
LWLockRelease(WALInsertLock);
|
||||
WriteRqst.Write = WriteRqstPtr;
|
||||
WriteRqst.Flush = WriteRqstPtr;
|
||||
}
|
||||
/* now wait for the write lock */
|
||||
LWLockAcquire(WALWriteLock, LW_EXCLUSIVE);
|
||||
LogwrtResult = XLogCtl->Write.LogwrtResult;
|
||||
if (!XLByteLE(record, LogwrtResult.Flush))
|
||||
else
|
||||
{
|
||||
WriteRqst.Write = WriteRqstPtr;
|
||||
WriteRqst.Flush = record;
|
||||
}
|
||||
XLogWrite(WriteRqst);
|
||||
}
|
||||
LWLockRelease(WALWriteLock);
|
||||
|
Reference in New Issue
Block a user