Re: BUG advisory_lock

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Eugen(dot)Konkov(at)aldec(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG advisory_lock
Date: 2008-06-19 14:27:57
Message-ID: 20080619142757.GQ5077@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Eugen(dot)Konkov(at)aldec(dot)com wrote:
> DECLARE
> varUnlocked boolean;
> BEGIN
> varUnlocked:= pg_try_advisory_lock( 783264760123456 ); -- Try to lock function
> IF not varUnlocked THEN return NULL; END IF; -- exit if locking is unsucessfull
>
> WRONG QUERY HERE WHICH INTERRUPT EXECUTION
>
> varUnlocked:= pg_advisory_unlock( 783264760123456 ); -- unlock function
> END
>
> NEXT time when I run this function I always get NULL until server reboot
>
> EXPECTED: Pg must unlock if function execution failed

You can unlock it in an EXCEPTION block to be safe.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Ati Rosselet 2008-06-20 16:38:46 BUG #4255: could not write to log file: Bad file descriptor
Previous Message Tom Lane 2008-06-19 14:10:52 Re: BUG advisory_lock