* Portions Copyright (c) 1996-2001, 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.52 2001/02/13 08:44:09 vadim Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.53 2001/02/13 20:40:25 vadim Exp $
*
*-------------------------------------------------------------------------
*/
if (updrqst)
{
S_LOCK(&(XLogCtl->info_lck));
+ LgwrResult = XLogCtl->LgwrResult;
if (XLByteLT(XLogCtl->LgwrRqst.Write, LgwrRqst.Write))
XLogCtl->LgwrRqst.Write = LgwrRqst.Write;
S_UNLOCK(&(XLogCtl->info_lck));
}
+/*
+ * We use this routine when Insert->curridx block is full and the next XLOG
+ * buffer looks as unwritten to OS' cache. insert_lck is assumed here.
+ */
static void
GetFreeXLBuffer()
{
uint16 curridx = NextBufIdx(Insert->curridx);
unsigned spins = 0;
+ /* Use Insert->LgwrResult copy if it's more fresh */
+ if (XLByteLT(LgwrResult.Write, Insert->LgwrResult.Write))
+ {
+ LgwrResult = Insert->LgwrResult;
+ if (XLByteLE(XLogCtl->xlblocks[curridx], LgwrResult.Write))
+ {
+ InitXLBuffer(curridx);
+ return;
+ }
+ }
+
LgwrRqst.Write = XLogCtl->xlblocks[Insert->curridx];
for (;;)
{
if (!TAS(&(XLogCtl->info_lck)))
{
LgwrResult = XLogCtl->LgwrResult;
+ /* LgwrRqst.Write GE XLogCtl->LgwrRqst.Write */
XLogCtl->LgwrRqst.Write = LgwrRqst.Write;
S_UNLOCK(&(XLogCtl->info_lck));
if (XLByteLE(XLogCtl->xlblocks[curridx], LgwrResult.Write))