It's not uncommon for various elements of the database to block each other. Queries can lock shared resources, system maintenance can temporarily prevent a transaction from committing; the list is endless. As a result, a critical aspect of troubleshooting a PostgreSQL system is tracking down blocked sessions, and what might be preventing normal operation.
There are two very powerful ways to decipher locks within PostgreSQL in the pg_locks view and the PostgreSQL 9.6+ pg_blocking_pids function. This recipe will demonstrate why these approaches are so useful.