calculation for NUM_FIXED_LWLOCKS

Started by Amit Kapilaover 11 years ago4 messages
#1Amit Kapila
amit.kapila16@gmail.com

Currently the calculation for NUM_FIXED_LWLOCKS is as
below, which I think has some problem:

/* Offsets for various chunks of preallocated lwlocks. */

#define BUFFER_MAPPING_LWLOCK_OFFSET NUM_INDIVIDUAL_LWLOCKS

#define LOCK_MANAGER_LWLOCK_OFFSET \

(BUFFER_MAPPING_LWLOCK_OFFSET + NUM_BUFFER_PARTITIONS)

#define PREDICATELOCK_MANAGER_LWLOCK_OFFSET \

(NUM_INDIVIDUAL_LWLOCKS + NUM_LOCK_PARTITIONS)

#define NUM_FIXED_LWLOCKS \

(PREDICATELOCK_MANAGER_LWLOCK_OFFSET + NUM_PREDICATELOCK_PARTITIONS)

In this PREDICATELOCK_MANAGER_LWLOCK_OFFSET

should consider NUM_BUFFER_PARTITIONS which means

it should be:

#define PREDICATELOCK_MANAGER_LWLOCK_OFFSET \

(*LOCK_MANAGER_LWLOCK_OFFSET* + NUM_LOCK_PARTITIONS)

If we don't consider buffer partitions in above calculation,
then the total shared memory allocated for fixed locks will
be wrong and can cause problems.

I have noticed this during my work on scaling shared
buffers where if I increase NUM_BUFFER_PARTITIONS,
it leads to hang for tpc-b test and as per my analysis
the reason is above calculation.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

#2Kevin Grittner
kgrittn@ymail.com
In reply to: Amit Kapila (#1)
Re: calculation for NUM_FIXED_LWLOCKS

Amit Kapila <amit.kapila16@gmail.com> wrote:

#define PREDICATELOCK_MANAGER_LWLOCK_OFFSET \
(NUM_INDIVIDUAL_LWLOCKS + NUM_LOCK_PARTITIONS)

In this PREDICATELOCK_MANAGER_LWLOCK_OFFSET
should consider NUM_BUFFER_PARTITIONS which means
it should be:

#define PREDICATELOCK_MANAGER_LWLOCK_OFFSET \
(LOCK_MANAGER_LWLOCK_OFFSET + NUM_LOCK_PARTITIONS)

Agreed.  It looks like a pasto in commit ea9df81.

Will commit a fix shortly.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Kevin Grittner
kgrittn@ymail.com
In reply to: Kevin Grittner (#2)
Re: calculation for NUM_FIXED_LWLOCKS

Kevin Grittner <kgrittn@ymail.com> wrote:

Will commit a fix shortly.

Fixed exactly as Amit suggested.  Pushed to master and 9.4 branches.

Thanks!

--

Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Amit Kapila
amit.kapila16@gmail.com
In reply to: Kevin Grittner (#3)
Re: calculation for NUM_FIXED_LWLOCKS

On Thu, Jun 19, 2014 at 7:41 PM, Kevin Grittner <kgrittn@ymail.com> wrote:

Kevin Grittner <kgrittn@ymail.com> wrote:

Will commit a fix shortly.

Fixed exactly as Amit suggested. Pushed to master and 9.4 branches.

Thanks for looking into it.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com