Re: Lock questions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Fernando <proyectolsd(at)wanadoo(dot)es>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Lock questions
Date: 2003-11-21 05:50:00
Message-ID: 9521.1069393800@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Fernando <proyectolsd(at)wanadoo(dot)es> writes:
> i've been reading the README file in the lmgr folder (in src/backend/storage/lmgr/) and i have a couple of questions about locks:
> - What's the difference between the Lightweight Locks (LWLocks) and
> the Regular locks (Heavyweight Locks)?

IIRC the differences are explained in that same README: no deadlock
detection in LWLocks is one of the more critical ones.

> For example, if i do a query and it needs a lock, would it be a lightweight one or a regular one?

All user-accessible locks are regular locks. LWLocks are used for
system internal processing (where, hopefully, we can prove that the
access pattern can't deadlock...). As an example, the regular lock
manager uses an LWLock to protect against simultaneous modifications
to its own data structures.

> - There are two lock methods, DEFAULT and USER. Where can I get more
information about them? In the README file it says that "USER locks are
non-blocking", how could this be?

See contrib/userlock/

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-11-21 05:54:49 Re: indexing with lower(...) -> queries are not optimised very well - Please Help
Previous Message Tom Lane 2003-11-21 05:04:46 Re: Psql bug?