Include foreign-key locks when reviewing atomic-write lock order
When adding explicit locks around an atomic write, include implicit foreign-key locks in the deadlock graph. A consistent application-level order can still cycle with an INSERT that checks referenced rows in another order. If the protected row’s key is not changing, PostgreSQL FO…