Re: Postgresql Database Lock Problem

From: shohorab hossain <shohorab23(at)yahoo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgresql Database Lock Problem
Date: 2009-11-18 08:41:09
Message-ID: 719578.64700.qm@web51709.mail.re2.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-docs pgsql-general

At first I would like to thank you all for your quick response.

Now my question is why two processes ID 19181 and 19196 are trying to access the same transaction 18386574 at the same time.

Here I have got Process ID, Transaction ID and SQL statement from pg_locks and pg_stat_activity view.
Is it possible to find from which Application form/window the query is being running.

With Thanks & Regards:
---------------------
Shohorab Hossain

----- Original Message ----
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
Sent: Wednesday, November 18, 2009 1:47:53
Subject: Re: [GENERAL] Postgresql Database Lock Problem

[ 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

Get your preferred Email name!
Now you can @ymail.com and @rocketmail.com.
http://mail.promotions.yahoo.com/newdomains/aa/

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Shruthi A 2009-11-18 13:09:20 Re: Can i write a time-trigger?
Previous Message shohorab hossain 2009-11-18 08:17:06 Re: [GENERAL] Postgresql Database Lock Problem

Browse pgsql-docs by date

  From Date Subject
Next Message Peter Eisentraut 2009-11-20 13:58:09 Re: vacuumdb clarification
Previous Message shohorab hossain 2009-11-18 08:17:06 Re: [GENERAL] Postgresql Database Lock Problem

Browse pgsql-general by date

  From Date Subject
Next Message shohorab hossain 2009-11-18 09:35:41 Re: Postgresql Database Lock Problem
Previous Message shohorab hossain 2009-11-18 08:17:06 Re: [GENERAL] Postgresql Database Lock Problem