Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4e9b159

Browse files
committed
Change order of operations during XLogFlush so that we try to include
in our write/flush operation any WAL entries that got queued while wewere waiting to get the WALWriteLock. This improves throughput whentransactions are small enough that several can be committed per WALwrite (ie, per disk revolution).
1 parent9a2e9c6 commit4e9b159

File tree

1 file changed

+23
-18
lines changed
  • src/backend/access/transam

1 file changed

+23
-18
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.107 2002/09/26 22:58:33 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.108 2002/10/07 17:04:30 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1252,28 +1252,33 @@ XLogFlush(XLogRecPtr record)
12521252
/* done already? */
12531253
if (!XLByteLE(record,LogwrtResult.Flush))
12541254
{
1255-
/* if something was added to log cache then try to flush this too */
1256-
if (LWLockConditionalAcquire(WALInsertLock,LW_EXCLUSIVE))
1257-
{
1258-
XLogCtlInsert*Insert=&XLogCtl->Insert;
1259-
uint32freespace=INSERT_FREESPACE(Insert);
1260-
1261-
if (freespace<SizeOfXLogRecord)/* buffer is full */
1262-
WriteRqstPtr=XLogCtl->xlblocks[Insert->curridx];
1263-
else
1264-
{
1265-
WriteRqstPtr=XLogCtl->xlblocks[Insert->curridx];
1266-
WriteRqstPtr.xrecoff-=freespace;
1267-
}
1268-
LWLockRelease(WALInsertLock);
1269-
}
12701255
/* now wait for the write lock */
12711256
LWLockAcquire(WALWriteLock,LW_EXCLUSIVE);
12721257
LogwrtResult=XLogCtl->Write.LogwrtResult;
12731258
if (!XLByteLE(record,LogwrtResult.Flush))
12741259
{
1275-
WriteRqst.Write=WriteRqstPtr;
1276-
WriteRqst.Flush=record;
1260+
/* try to write/flush later additions to XLOG as well */
1261+
if (LWLockConditionalAcquire(WALInsertLock,LW_EXCLUSIVE))
1262+
{
1263+
XLogCtlInsert*Insert=&XLogCtl->Insert;
1264+
uint32freespace=INSERT_FREESPACE(Insert);
1265+
1266+
if (freespace<SizeOfXLogRecord)/* buffer is full */
1267+
WriteRqstPtr=XLogCtl->xlblocks[Insert->curridx];
1268+
else
1269+
{
1270+
WriteRqstPtr=XLogCtl->xlblocks[Insert->curridx];
1271+
WriteRqstPtr.xrecoff-=freespace;
1272+
}
1273+
LWLockRelease(WALInsertLock);
1274+
WriteRqst.Write=WriteRqstPtr;
1275+
WriteRqst.Flush=WriteRqstPtr;
1276+
}
1277+
else
1278+
{
1279+
WriteRqst.Write=WriteRqstPtr;
1280+
WriteRqst.Flush=record;
1281+
}
12771282
XLogWrite(WriteRqst);
12781283
}
12791284
LWLockRelease(WALWriteLock);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp