From: | Marc <pgsql-general(at)mbreslow(dot)net> |
---|---|
To: | "Richard Huxton" <dev(at)archonet(dot)com> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Exclusive Locks Taken on User Tables? |
Date: | 2007-11-06 19:32:50 |
Message-ID: | 809128960711061132i45186c4fl67aff913cc59864f@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
This is the query that I'm running to view locks:
SELECT pg_class.relname AS table,
pg_database.datname AS database,
transaction, pid, mode, granted
FROM pg_locks, pg_class, pg_database
WHERE pg_locks.relation = pg_class.oid
AND pg_locks.database = pg_database.oid
ORDER BY pg_class.relname, mode
I'm pretty sure this filters out transactionid lock types because I'm
joining to pg_database and pg_class. Pls correct me if I'm wrong though.
On Nov 6, 2007 2:22 PM, Richard Huxton <dev(at)archonet(dot)com> wrote:
> Marc wrote:
> > Hi,
> >
> > I'm seeing an "EXCLUSIVE" lock being taken on a table even though the
> > documentation says that "This lock mode is not automatically acquired on
> > user tables by any PostgreSQL command."
>
> Hmm - are you sure?
>
> > My SQL is
> > UPDATE users SET online = $1 where username = $2
> >
> > username is the PK on the users table.
>
> Difficult to believe that's locking the whole table.
>
> > Other locks taken by the transaction are 1 RowExclusiveLock for the
> users
> > table and 1 RowExclusiveLock on each of the 6 explict indexes on that
> table
> > and another for the implicity users_pkey index.
>
> Fair enough.
>
> > The result of these locks is that concurrent calls for the same
> statement
> > are being serialized because the ExclusiveLock being requested is not
> being
> > granted.
>
> Doesn't sound right.
>
> Are you sure your ExclusiveLock isn't on a "transactionid" rather than a
> "relation"? Every transaction has an exclusive lock on itself.
>
> Are you sure subsequent transactions affecting that row aren't just
> waiting to see if the original commits? That's normal behaviour.
>
> --
> Richard Huxton
> Archonet Ltd
>
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2007-11-06 19:38:56 | Re: Syntax error in a large COPY |
Previous Message | Richard Huxton | 2007-11-06 19:22:31 | Re: Exclusive Locks Taken on User Tables? |