Matt Mello <alien(at)spaceship(dot)com> writes:
> From what I understand, two UPDATEs are trying to update different
> fields of the same records at the same time. Sometimes one of the
> updates gets this error, sometimes the other. I can code around it, but
> I want to be able to prevent this in new situations in the future.
> Here are the updates:
> UPDATE txn
> SET batchid = 19391
> WHERE txn.terminalid = 38 AND yadayada
> UPDATE txn
> SET drawerid = 50123
> WHERE txn.terminalid = 38 AND yadayada
I can't see a reason for bare UPDATEs of that sort to get deadlocks.
There must be some other factor involved. Do you have triggers, rules,
or foreign keys on this table? Other locks being taken in the same
transaction?
regards, tom lane