Next time this is happening join the pg_lock table to the pg_stat_activity table to see which query is holding the lock for a bazillion milliseconds, while it's happening. That query / statement may give you some clue what's wrong.
pgsql-docs by date:
Соглашаюсь с условиями обработки персональных данных