Running postgresql 11.2
I've got 3 tables, Table1, Table2 and Table3.
Table2 and Table3 are linked to Table1.
So, both have a foreign key and a field for this:
"fk38dc51d86836z0e5" FOREIGN KEY (table1_id) REFERENCES table1(id)
I recently got a deadlock on these 2 tables, despite the involved queries not using the foreign key field.
Process 19819 waits for ShareLock on transaction 254244062; blocked by process 19930.
Process 19930 waits for ShareLock on transaction 254244063; blocked by process 19819.
Process 19819: update Table1 set lastUpdated=$1, user_id=$2 where id=$3
Process 19930: update Table2 set lastUpdated=$1, version=$2, content=$3, extra=$4 where id=$5 and version=$6
The only link between these 2 tables is their link to Table1. They are not directly linked to each other.
But neither query uses the foreign key to Table1 as part of their query.
What is going on here? Why the deadlock at all?