aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/buffer/bufmgr.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2001-02-18 04:39:42 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2001-02-18 04:39:42 +0000
commit33cc5d8a4d0dd7cdf78c6a6851b37799854191d4 (patch)
tree8d9334993e788eb21dd4c3374174effabaedd43c /src/backend/storage/buffer/bufmgr.c
parent58c4ab9d6265102d949a0d9035e48a752b3b457f (diff)
downloadpostgresql-33cc5d8a4d0dd7cdf78c6a6851b37799854191d4.tar.gz
postgresql-33cc5d8a4d0dd7cdf78c6a6851b37799854191d4.zip
Change s_lock to not use any zero-delay select() calls; these are just a
waste of cycles on single-CPU machines, and of dubious utility on multi-CPU machines too. Tweak s_lock_stuck so that caller can specify timeout interval, and increase interval before declaring stuck spinlock for buffer locks and XLOG locks. On systems that have fdatasync(), use that rather than fsync() to sync WAL log writes. Ensure that WAL file is entirely allocated during XLogFileInit.
Diffstat (limited to 'src/backend/storage/buffer/bufmgr.c')
-rw-r--r--src/backend/storage/buffer/bufmgr.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index 6af9b4065d3..5c5b6b8875c 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.106 2001/01/24 19:43:05 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.107 2001/02/18 04:39:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1990,6 +1990,9 @@ UnlockBuffers(void)
}
}
+/* Max time to wait to acquire a buffer read or write lock */
+#define BUFFER_LOCK_TIMEOUT (10*60*1000000) /* 10 minutes */
+
void
LockBuffer(Buffer buffer, int mode)
{
@@ -2041,7 +2044,7 @@ LockBuffer(Buffer buffer, int mode)
{
S_UNLOCK(&(buf->cntx_lock));
RESUME_INTERRUPTS();
- S_LOCK_SLEEP(&(buf->cntx_lock), i++);
+ S_LOCK_SLEEP(&(buf->cntx_lock), i++, BUFFER_LOCK_TIMEOUT);
HOLD_INTERRUPTS();
S_LOCK(&(buf->cntx_lock));
}
@@ -2069,7 +2072,7 @@ LockBuffer(Buffer buffer, int mode)
}
S_UNLOCK(&(buf->cntx_lock));
RESUME_INTERRUPTS();
- S_LOCK_SLEEP(&(buf->cntx_lock), i++);
+ S_LOCK_SLEEP(&(buf->cntx_lock), i++, BUFFER_LOCK_TIMEOUT);
HOLD_INTERRUPTS();
S_LOCK(&(buf->cntx_lock));
}