From c0e9b3139fe24b9bcfcd660fd106ddf2e2d50703 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Sat, 22 Jul 2006 21:04:40 +0000
Subject: [PATCH] Hmm, seems --disable-spinlocks has been broken for awhile and
 nobody noticed.  Fix SpinlockSemas() to report the correct count considering
 that PG 8.1 adds a spinlock to each shared-buffer header.

---
 src/backend/storage/lmgr/spin.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/backend/storage/lmgr/spin.c b/src/backend/storage/lmgr/spin.c
index 220f8b4b73f..1a7fff2f782 100644
--- a/src/backend/storage/lmgr/spin.c
+++ b/src/backend/storage/lmgr/spin.c
@@ -16,12 +16,14 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/storage/lmgr/spin.c,v 1.20 2006/07/14 14:52:23 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/backend/storage/lmgr/spin.c,v 1.21 2006/07/22 21:04:40 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
 #include "postgres.h"
 
+#include "miscadmin.h"
+#include "storage/lwlock.h"
 #include "storage/spin.h"
 
 
@@ -53,9 +55,9 @@ SpinlockSemas(void)
 	 * similar to the way shmem space estimation is handled.
 	 *
 	 * For now, though, we just need a few spinlocks (10 should be plenty)
-	 * plus one for each LWLock.
+	 * plus one for each LWLock and one for each buffer header.
 	 */
-	return NumLWLocks() + 10;
+	return NumLWLocks() + NBuffers + 10;
 }
 
 /*
-- 
GitLab