Re: Postgresql Database Lock Problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: shohorab hossain <shohorab23(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgresql Database Lock Problem
Date: 2009-11-17 19:47:53
Message-ID: 3159.1258487273@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-docs pgsql-general

[ cc's trimmed a bit ]

shohorab hossain <shohorab23(at)yahoo(dot)com> writes:
> LOG: process 19181 still waiting for ShareLock on transaction 18025221
> after 1002.251 ms
> STATEMENT: SELECT CurrentNext, CurrentNextSys, IncrementNo, Prefix, Suffix,
> DecimalPattern, AD_Sequence_ID FROM AD_Sequence WHERE Name = $1 AND
> AD_Client_ID = $2 AND IsActive='Y' AND IsTableID='N' AND
> IsAutoSequence='Y' ORDER BY AD_Client_ID DESC FOR UPDATE OF
> AD_Sequence

> LOG: process 19181 acquired ShareLock on transaction 18025221 after
> 1298870.572 ms
> STATEMENT: SELECT CurrentNext, CurrentNextSys, IncrementNo, Prefix, Suffix,
> DecimalPattern, AD_Sequence_ID FROM AD_Sequence WHERE Name = $1 AND
> AD_Client_ID = $2 AND IsActive='Y' AND IsTableID='N' AND
> IsAutoSequence='Y' ORDER BY AD_Client_ID DESC FOR UPDATE OF
> AD_Sequence

It looks to me like the database is doing exactly what you are telling
it to, ie, waiting until it can get an update lock on the selected
row(s) of AD_Sequence. What you need to look into is what the other
transaction was doing that caused it to sit on uncommitted changes to
those rows for 1300 seconds. Most likely this is an application bug or
bad application design (like failing to commit changes reasonably
promptly, or maybe not understanding the semantics of FOR UPDATE in
the first place).

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Scott Marlowe 2009-11-17 20:55:25 Re: [GENERAL] Postgresql Database Lock Problem
Previous Message Plugge, Joe R. 2009-11-17 19:31:49 Re: Postgresql Database Lock Problem

Browse pgsql-docs by date

  From Date Subject
Next Message Scott Marlowe 2009-11-17 20:55:25 Re: [GENERAL] Postgresql Database Lock Problem
Previous Message Plugge, Joe R. 2009-11-17 19:31:49 Re: Postgresql Database Lock Problem

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2009-11-17 19:55:48 Re: build array of composites in SPI
Previous Message Naoko Reeves 2009-11-17 19:47:35 does encrypt function support higher than basic ascii?