"Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> Now, the scripts are wrap'd in a BEGIN/END ... if a file fails to be
> loaded, I want the whole thing to rollback ... the deadlock itself, I'm
> presuming, is because two servers are trying to update the same
> $ip_id/$port/$company_id record, at the same time ...
Actually, the problem is more likely that two servers try to update two
different rows in opposite orders. It's not possible to deadlock when
only one lock is involved.
You could work around this by ensuring that all sessions update rows in
a consistent order; for instance, at the beginning of a transaction sort
your intended updates by primary key and then apply in that order.
regards, tom lane