Reputation: 365
I'm working with a PostgreSQL statement. My goal is to modify the statement to avoid the deadlock problem. Currently, there are 2 statements updating the same records. This must happen in some times and cannot be avoided because it's the real operation in the production.
What I want to do is to create the UPDATE
statement that will obtain lock to all records that will be updated. I have tried SELECT FOR UPDATE
, LOCK TABLE as exclusive mode
, UPDATE
in a LOOP
". Neither has worked for me. The deadlock still happened. You guys who have any ideas for this?
Upvotes: 0
Views: 492
Reputation: 8105
Mind using advisory locking, in case you cannot figure out the exact relations or records to lock.
Upvotes: 1