|
7 | 7 | * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California
|
9 | 9 | *
|
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 $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -1252,28 +1252,33 @@ XLogFlush(XLogRecPtr record)
|
1252 | 1252 | /* done already? */
|
1253 | 1253 | if (!XLByteLE(record,LogwrtResult.Flush))
|
1254 | 1254 | {
|
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 |
| -} |
1270 | 1255 | /* now wait for the write lock */
|
1271 | 1256 | LWLockAcquire(WALWriteLock,LW_EXCLUSIVE);
|
1272 | 1257 | LogwrtResult=XLogCtl->Write.LogwrtResult;
|
1273 | 1258 | if (!XLByteLE(record,LogwrtResult.Flush))
|
1274 | 1259 | {
|
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 | +} |
1277 | 1282 | XLogWrite(WriteRqst);
|
1278 | 1283 | }
|
1279 | 1284 | LWLockRelease(WALWriteLock);
|
|