We use check_postgres.pl to monitor our database.
We use this to check the count of the locks:
https://bucardo.org/check_postgres/check_postgres.pl.html#locks
We often see more than 150 locks.
The question was: What is going on? We patched the script to output this sql statement, if the lock count was exceeded:
select * from pg_stat_activity order by datname
Unfortunately the result is not what I was expecting. Although there are more than 150 locks, pg_stat_activity shows only few (less then 10) queries.
This has happened about twice a day during the last days, and every time only few lines where returned by pg_stat_activity.
What is going on here?
How to debug the current DB state if there are too many locks?
pg_stat_activity
doesn't show "queries", it shows open connections. That is something completely different.