Lock structures

Started by Bruce Momjianabout 25 years ago7 messageshackers
Jump to latest
#1Bruce Momjian
bruce@momjian.us

Can someone explain why LockMethodCtl is in shared memory while
LockMethodTable is in postmaster memory context?

I realize LockMethodCtl has a spinlock, so it has to be in shared
memory, but couldn't it all be put in shared memory?

Also, the code:

LockShmemSize(int maxBackends)
{
int size = 0;

size += MAXALIGN(sizeof(PROC_HDR)); /* ProcGlobal */
size += MAXALIGN(maxBackends * sizeof(PROC)); /* each MyProc*/
size += MAXALIGN(maxBackends * sizeof(LOCKMETHODCTL)); /* each
* lockMethodTable->ctl */

Is there one LOCKMETHODCTL for every backend? I thought there was only
one of them.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#1)
Re: Lock structures

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Can someone explain why LockMethodCtl is in shared memory while
LockMethodTable is in postmaster memory context?
I realize LockMethodCtl has a spinlock, so it has to be in shared
memory, but couldn't it all be put in shared memory?

I think the original point was not to assume that the shared-memory
pointers would be the same in each backend. Right now we don't need
that, but I see no good reason to change the data structure.

size += MAXALIGN(maxBackends * sizeof(LOCKMETHODCTL)); /* each
* lockMethodTable->ctl */

Is there one LOCKMETHODCTL for every backend? I thought there was only
one of them.

You're right, that line is erroneous; it should read

size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LOCKMETHODCTL));

Not a significant error but it should be changed for clarity ...

regards, tom lane

#3Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
Re: Lock structures

Is there one LOCKMETHODCTL for every backend? I thought there was only
one of them.

You're right, that line is erroneous; it should read

size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LOCKMETHODCTL));

Not a significant error but it should be changed for clarity ...

I assume the fix should be done in 7.2, not 7.1, right?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#3)
Re: Lock structures

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Is there one LOCKMETHODCTL for every backend? I thought there was only
one of them.

You're right, that line is erroneous; it should read

size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LOCKMETHODCTL));

Not a significant error but it should be changed for clarity ...

I assume the fix should be done in 7.2, not 7.1, right?

I see no reason to put it off ...

regards, tom lane

#5Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#4)
Re: Lock structures

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Is there one LOCKMETHODCTL for every backend? I thought there was only
one of them.

You're right, that line is erroneous; it should read

size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LOCKMETHODCTL));

Not a significant error but it should be changed for clarity ...

I assume the fix should be done in 7.2, not 7.1, right?

I see no reason to put it off ...

Tom, what about the names? There is LOCKMETHODCTL, LOCKMETHODTABLE,
and LOCKMODES. How about LOCKSTYLESHARED, LOCKSTYLE, and leave
LOCKMODES unchanged?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#5)
Re: Lock structures

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom, what about the names? There is LOCKMETHODCTL, LOCKMETHODTABLE,
and LOCKMODES. How about LOCKSTYLESHARED, LOCKSTYLE, and leave
LOCKMODES unchanged?

I think both of those names are worse (less descriptive) than what
we have ...

regards, tom lane

#7Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#4)
Re: Lock structures

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Is there one LOCKMETHODCTL for every backend? I thought there was only
one of them.

You're right, that line is erroneous; it should read

size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LOCKMETHODCTL));

Not a significant error but it should be changed for clarity ...

I assume the fix should be done in 7.2, not 7.1, right?

I see no reason to put it off ...

Thanks. Fix applied.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026