mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Calculate # of semaphores correctly with --disable-spinlocks.
The old formula didn't take into account that each WAL sender process needs a spinlock. We had also already exceeded the fixed number of spinlocks reserved for misc purposes (10). Bump that to 30. Backpatch to 9.0, where WAL senders were introduced. If I counted correctly, 9.0 had exactly 10 predefined spinlocks, and 9.1 exceeded that, but bump the limit in 9.0 too because 10 is uncomfortably close to the edge.
This commit is contained in:
parent
a0c2492b95
commit
9508754ed7
@ -23,6 +23,7 @@
|
|||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
|
#include "replication/walsender.h"
|
||||||
#include "storage/lwlock.h"
|
#include "storage/lwlock.h"
|
||||||
#include "storage/spin.h"
|
#include "storage/spin.h"
|
||||||
|
|
||||||
@ -50,14 +51,21 @@ SpinlockSemas(void)
|
|||||||
int
|
int
|
||||||
SpinlockSemas(void)
|
SpinlockSemas(void)
|
||||||
{
|
{
|
||||||
|
int nsemas;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* It would be cleaner to distribute this logic into the affected modules,
|
* It would be cleaner to distribute this logic into the affected modules,
|
||||||
* similar to the way shmem space estimation is handled.
|
* similar to the way shmem space estimation is handled.
|
||||||
*
|
*
|
||||||
* For now, though, we just need a few spinlocks (10 should be plenty)
|
* For now, though, there are few enough users of spinlocks that we just
|
||||||
* plus one for each LWLock and one for each buffer header.
|
* keep the knowledge here.
|
||||||
*/
|
*/
|
||||||
return NumLWLocks() + NBuffers + 10;
|
nsemas = NumLWLocks(); /* one for each lwlock */
|
||||||
|
nsemas += NBuffers; /* one for each buffer header */
|
||||||
|
nsemas += max_wal_senders; /* one for each wal sender process */
|
||||||
|
nsemas += 30; /* plus a bunch for other small-scale use */
|
||||||
|
|
||||||
|
return nsemas;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user