Is there a way to get pg_stat_activity information

2020-04-14 09:13发布

pg_stat_activity holds extremely useful information for post-mortem analysis of various issues, especially concurrency-related, and so augmenting errors or logging with this data (properly filtered and correlated) is invaluable. However querying it requires getting a database connection which might be in short supply at the very moment it's most needed.

Is there a side-channel of some sort which would allow getting that information without the additional database connection?

1条回答
我命由我不由天
2楼-- · 2020-04-14 09:24

Not really, but the parameter superuser_reserved_connections will help you. It defines the number of connections that are reserved for superusers precisely so that they can still connect, even if the connection limit is exhausted.

Set the value high enough and have your monitoring process connect as superuser.

查看更多
登录 后发表回答