Common misconceptions about locking in PostgreSQL
Developers tend to forget that there’s a lock queue. Let me show you why you should always remember that.
Let’s go back to our two concurrent sessions again. First one has an open transaction that holds an AccessShareLock on our table, second has a waiting AccessExclusiveLock in order to drop the table.
Let’s fire up two more sessions. Observe: