Search Postgresql Archives

Re: [Fwd: Re: deadlock on the same relation]

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

 



"Francesco Formenti - TVBLOB S.r.l." <francesco.formenti@xxxxxxxxxx> writes:
> Tom Lane wrote:
>> Probably you have been careless about avoiding "lock upgrade"
>> situations.

> Unfortunately, the first operation I do after the "BEGIN" declaration is 
> the LOCK TABLE in access exclusive mode, and is the only explicit lock I 
> perform in all the stored procedures.

If you mean that you placed a LOCK TABLE inside the stored procedure,
that's far from being the same thing as the start of the transaction.
For example, if your application does

	BEGIN;
	SELECT * FROM mytab;
	SELECT myprocedure();
	COMMIT;

then by the time control arrives inside myprocedure your transaction
already holds a nonexclusive lock on "mytab".  If you do LOCK TABLE mytab
inside the function then you're risking deadlock.

			regards, tom lane


[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