More information on how to understand table pg_locks. - Mailing list pgsql-general

From Olivier Ceulemans
Subject More information on how to understand table pg_locks.
Date
Msg-id 851ED96B0D9E1C4AB63E741DAFCEBD1CC20AA7@exchange1.ad.irislink.com
Whole thread Raw
Responses Re: More information on how to understand table pg_locks.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general

Hi All,

 

I wrote an application making ‘advanced’ use of transactions. The application is not tied to a specific kind of database. It runs fine on oracle, db2, sql server but I run into a deadlock on postgresql.

I have two transactions (let’s say A & B). These two transactions are initiated by the same thread and I’m alone on the database and the problem can be reproduced at will on postgresql. So this is not a random problem.

 

I try to understand what I see in the pg_locks table but it looks like what is found there should never occur according to the manual…

 

 

At deadlock time:

For transaction A, I have a RowShareLock on table X. I have no idea on how/why this RowShareLock is acquired by my application. In transaction A, I never read/write ‘directly’ to the table X. However I create data in other tables that have foreign keys to table X.

-> Is there more information available somewhere in postgres system tables ?

-> Could these foreign keys be the cause of this RowShareLock ?

 

For transaction B, I have a AccessShareLock, ExclusiveLock and RowExclusiveLock on table X.

-> According to the manual, ExclusiveLock occurs only on system tables.

-> Is there a way to find why this lock is acquired ?

 

Do you know tools to help in debugging this ?

 

Any help is appreciated…

 

Thanks in advance

 

pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Multi DB performance test
Next
From: "Dmitry Koterov"
Date:
Subject: How to disable displaying of a NOTICE context?