Search Postgresql Archives

Re: Waiting on a transaction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2005-08-16 at 12:01 -0700, Bill Moseley wrote:
> I wondered if my application should set an alarm and timeout
> with an error if, by odd chance, an update hangs.

Here's a way to handle this under the upcoming 8.1 release:

Before you execute the update you can execute SELECT ... FOR UPDATE
NOWAIT to select anything (e.g. dummy constant) from the row that you
want to update.  If no error is thrown then you have a lock on your row
and you can confidently proceed with your update.  Otherwise someone has
that row locked.  At that point you can loop and retry if you want.

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux