Re: Updates, ShareLocks, RowExclusiveLocks, and deadlocks - Mailing list pgsql-general

From Tom Lane
Subject Re: Updates, ShareLocks, RowExclusiveLocks, and deadlocks
Date
Msg-id 27303.1335383106@sss.pgh.pa.us
Whole thread Raw
In response to Re: Updates, ShareLocks, RowExclusiveLocks, and deadlocks  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Martijn van Oosterhout <kleptog@svana.org> writes:
> I think what you're missing here is that RowExclusiveLocks are taken by
> marking the row itself.

More specifically: row-level locks are not reflected in pg_locks at all.
A RowExclusiveLock entry in pg_locks reflects a *table* level lock,
which is taken by any INSERT/UPDATE/DELETE command on the table,
independently of how many rows it modifies (even zero).  The purpose
of that type of lock is to prevent concurrent DDL changes on the table,
not to serialize the row-level operations.

There are locks that will show up in pg_locks that are taken transiently
when attempting to mark a row modified, but they don't persist after the
mark has been made, and the details have changed from time to time in
different PG versions.  So I'd suggest testing it to see exactly what
you get.

            regards, tom lane

pgsql-general by date:

Previous
From: Ben Chobot
Date:
Subject: Re: Updates, ShareLocks, RowExclusiveLocks, and deadlocks
Next
From: Guillaume Lelarge
Date:
Subject: Re: how robust are custom dumps?