PostgreSQL - Transactions and Concurrency
You have the following PostgreSQL code causing a deadlock:
What is the main issue causing the deadlock?
BEGIN;
LOCK TABLE orders IN ACCESS EXCLUSIVE MODE;
UPDATE customers SET name = 'Alice' WHERE id = 1;
-- Transaction 2 starts here
BEGIN;
LOCK TABLE customers IN ACCESS EXCLUSIVE MODE;
UPDATE orders SET status = 'shipped' WHERE id = 10;
What is the main issue causing the deadlock?
