Deadlock between select and truncate (postgresql)

Posted by valodzka on Stack Overflow See other posts from Stack Overflow or by valodzka
Published on 2010-05-19T15:29:43Z Indexed on 2010/05/19 16:20 UTC
Read the original article Hit count: 234

Filed under:
|

Table output_values_center1 (and some other) inherits output_values. Periodically I truncate table output_values_center1 and load new data (in one transaction). In that time user can request some data and he got error message. Why it ever happens (select query requests only one record) and how to avoid such problem:

2010-05-19 14:43:17 UTC ERROR:  deadlock detected
2010-05-19 14:43:17 UTC DETAIL:  Process 25972 waits for AccessShareLock on relation  2495092 of database 16385; blocked by process 26102.
    Process 26102 waits for AccessExclusiveLock on relation 2494865 of database 16385; blocked by process 25972.
    Process 25972: SELECT * FROM "output_values" WHERE ("output_values".id = 122312)  LIMIT 1
    Process 26102: TRUNCATE TABLE "output_values_center1"

© Stack Overflow or respective owner

Related posts about postgresql

Related posts about deadlock