ExclusiveLock

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: testperf-general(at)pgfoundry(dot)org
Subject: ExclusiveLock
Date: 2004-11-08 19:56:55
Message-ID: 1099943815.6942.7007.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Recent runs of DBT-2 show very occasional ExclusiveLock (s) being held
by transactions, sometimes waiting to be granted.

On Sat, Nov 06, 2004 at 11:40:49AM +0000, Simon Riggs wrote:
> > The lockstats just show there's all those Exclusive Locks on
order_line, right?:
>
> http://www.osdl.org/projects/dbt2dev/results/dev4-010/191/db/lockstats.out
> >
>
> The output is...
> relname | pid | mode | granted
> ---------------+-------+------------------+---------
> new_order | 21735 | AccessShareLock | t
> new_order | 21735 | RowExclusiveLock | t
> orders | 21715 | AccessShareLock | t
> orders | 21715 | RowExclusiveLock | t
> pg_class | 23254 | AccessShareLock | t
> order_line | 21715 | AccessShareLock | t
> order_line | 21715 | RowExclusiveLock | t
> order_line | 21735 | ExclusiveLock | f
> new_order | 21715 | AccessShareLock | t
...
>
> which shows a non-granted lock, waiting for a Table-level
ExclusiveLock
> on order_line. This is unexpected
(by me, that is...)

According to the manual, Exclusive Lock is not normally held by SQL
statements. There are no LOCK TABLE statements in DBT-2.

My digging reveals that ExclusiveLock is held on user relations by
_bt_getbuf() - when we extend a btree relation by one page

I also find ExclusiveLock is held by
- LISTEN/NOTIFY
- XactLockTableInsert()/XactLockTableDelete()
but those don't look like they lock user relations

LockAcquire() says its locks show in lock tables, so is index extension
the source of the ExclusiveLocks shown in the lock output? Presumably
they would be short duration, so you wouldn't see them unless you caught
it at just the right moment....unless we start to queue up on the
leadingedge of the index.

I expect index extension to be a source of contention anyway, but are we
actually *seeing* it? Or is it another issue, and is this an 8.0
problem?

--
Best Regards, Simon Riggs

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message D'Arcy J.M. Cain 2004-11-08 20:29:16 Re: View pg_stat_activity slow to get up to date
Previous Message oozmen 2004-11-08 18:48:55 How to create/initialize/access an execution plan