Re: Record locking in deadlock

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Robert Wille <a2om6sy02(at)sneakemail(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Record locking in deadlock
Date: 2003-07-06 01:37:25
Message-ID: 20030705183327.F47836-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Thu, 3 Jul 2003, Robert Wille wrote:

> I no longer believe that I have gotten into a deadlock situation, but
> rather, it appears that somehow a portion of my table somehow gets locked,
> and stays locked, even after whatever locked it is done. I have added code
> to my application to track what every connection is doing. In the two cases
> I have been able to analyze, when the problem first occurs, all connections
> are hung trying to do single row updates, except for one, which is reading.
> A multi-row update eventually joins the throng of blocked updates, but it
> appears that the first calls that end up blocking invariably are single-row
> updates.
>
> Incidentally, these single-row updates occur within a transaction. Nothing
> else happens in the transaction, so it should be irrelevant, but I thought
> I'd mention it anyway.
>
> Any idea how this could happen or how to track it down? Is there any way to
> look at what records are locked, and what caused them to be locked?

I'd wonder if you're possibly running into concurrency problems from
foreign keys. Is it possible that you're ending up locking the same row
in a primary key table somewhere on the constraint checks? That'd still
leave you with needing to find which transaction is holding the lock you
want.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2003-07-06 02:10:25 Re: Record locking in deadlock
Previous Message Hannu Krosing 2003-07-06 00:11:58 Re: PostgreSQL vs. MySQL