> Are you sure it's deadlocking? I.e. it's rolling back because of
> "Deadlock detected" errors?
That's right.
> > How can a statement like this deadlock? Doesn't it
> > acquire all necessary locks atomically?
>
> Yes. The problem is in the case where another transaction is holding
> something on the table. Postgres has a deadlock_timeout feature
> which is there to prevent clients from waiting forever. What's yours
> set at? Maybe you just need to set it higher.
I haven't changed this from the default (~20 seconds?). Is it a strict
first-in-first-out queue? Because there's a lot of other transactions
trying to update smaller portions of this table that seem to be cutting in
front of the line for the lock so to speak.
-Jonathan