"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