Re: App very unresponsive while performing simple update

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

 



Brendan Duddridge <brendan@xxxxxxxxxxxxxx> writes:

> Further to my issue, the update never did finish. I received the  following
> message in psql:
> 
> ssprod=# update product set is_hungry = 'true'  where date_modified >
> current_date - 10;
> ERROR:  deadlock detected
> DETAIL:  Process 18778 waits for ShareLock on transaction 711698780;   blocked
> by process 15784.
> Process 15784 waits for ShareLock on transaction 711697098; blocked  by process
> 18778.

What queries are those two processes executing? And what foreign keys do you
have on the product table or elsewhere referring to the product table? And
what indexes do you have on those columns?

I think this indicates you have foreign keys causing the deadlock. One process
is waiting until an update elsewhere finishes before modifying a record that
other update refers to via a foreign key. But that other process is waiting
similarly for the first one.

Do you have any foreign keys in other tables referring to the product table?
Do you have indexes on those other tables? The update needs to check those
other tables to make sure there are no references to the records you're
updating. If there's no index it has to do a sequential scan.

To get a deadlock I think you would need another update running somewhere
though.



-- 
greg



[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux