Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7e04843

Browse files
committed
Comments about GetFreeXLBuffer().
GetFreeXLBuffer(): use Insert->LgwrResult instead of private LgwrResult copy if it's more fresh (attempt to avoid acquiring info_lck/lgwr_lck).
1 parent 3d21bf8 commit 7e04843

File tree

1 file changed

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

1 file changed

+18
-1
lines changed

src/backend/access/transam/xlog.c

+18-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.52 2001/02/13 08:44:09 vadim Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.53 2001/02/13 20:40:25 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -612,6 +612,7 @@ begin:;
612612
if (updrqst)
613613
{
614614
S_LOCK(&(XLogCtl->info_lck));
615+
LgwrResult = XLogCtl->LgwrResult;
615616
if (XLByteLT(XLogCtl->LgwrRqst.Write, LgwrRqst.Write))
616617
XLogCtl->LgwrRqst.Write = LgwrRqst.Write;
617618
S_UNLOCK(&(XLogCtl->info_lck));
@@ -760,6 +761,10 @@ XLogFlush(XLogRecPtr record)
760761

761762
}
762763

764+
/*
765+
* We use this routine when Insert->curridx block is full and the next XLOG
766+
* buffer looks as unwritten to OS' cache. insert_lck is assumed here.
767+
*/
763768
static void
764769
GetFreeXLBuffer()
765770
{
@@ -768,12 +773,24 @@ GetFreeXLBuffer()
768773
uint16 curridx = NextBufIdx(Insert->curridx);
769774
unsigned spins = 0;
770775

776+
/* Use Insert->LgwrResult copy if it's more fresh */
777+
if (XLByteLT(LgwrResult.Write, Insert->LgwrResult.Write))
778+
{
779+
LgwrResult = Insert->LgwrResult;
780+
if (XLByteLE(XLogCtl->xlblocks[curridx], LgwrResult.Write))
781+
{
782+
InitXLBuffer(curridx);
783+
return;
784+
}
785+
}
786+
771787
LgwrRqst.Write = XLogCtl->xlblocks[Insert->curridx];
772788
for (;;)
773789
{
774790
if (!TAS(&(XLogCtl->info_lck)))
775791
{
776792
LgwrResult = XLogCtl->LgwrResult;
793+
/* LgwrRqst.Write GE XLogCtl->LgwrRqst.Write */
777794
XLogCtl->LgwrRqst.Write = LgwrRqst.Write;
778795
S_UNLOCK(&(XLogCtl->info_lck));
779796
if (XLByteLE(XLogCtl->xlblocks[curridx], LgwrResult.Write))

0 commit comments

Comments
 (0)