February 2020
Intermediate to advanced
734 pages
38h 13m
English
Create a blocking scenario with the following steps:
CREATE TABLE lock_test (junk INT); BEGIN; LOCK TABLE lock_test IN EXCLUSIVE MODE;
INSERT INTO lock_test (junk) VALUES (42);
Next, investigate the problem with these steps (PostgreSQL 9.6 and above only):
SELECT pid, locktype, mode, granted,
relation::REGCLASS::TEXT AS locked_object
FROM pg_locks
WHERE relation IS NOT NULL
ORDER BY relation, granted DESC;
SELECT p.pid, p.query, s.pid AS blocker_pid, s.query AS blocker_query FROM pg_stat_activity ...
Read now
Unlock full access