From tests we made in PostgreSQL, it seems an ungranted access exclusive lock to a table is blocking an access share lock. Below describes the test that we executed.
Session 1:
begin;
select * from users where id = 1;
Note: Transaction is intentionally left open for the test
Session 2:
alter table users add column foo boolean;
Note: This statement is blocked by the statement in Session 1. Access exclusive lock is not yet granted.
Session 3:
select * from users where id = 2;
The last statement in Session 3 is blocked.
How is it blocked when the access exclusive lock from the alter statement has not yet been granted (since it's blocked by Session 1)? Is there something that we're missing?