Skip to content

Support passive monitoring of Postgres locks - #285

Open
Hawxy wants to merge 2 commits into
madelson:masterfrom
Hawxy:passivemonitoring
Open

Support passive monitoring of Postgres locks#285
Hawxy wants to merge 2 commits into
madelson:masterfrom
Hawxy:passivemonitoring

Conversation

@Hawxy

Copy link
Copy Markdown

Hiya, I've used this package quite a lot over the last few years, both in my work as well as open source (I moved MartenDB over to it a while ago, and it'll be used within the v1 of Wallaby). I find the lock monitoring especially useful and it eliminated an entire class of problems for us, but the pg_sleep query causes a few issues:

  • Users tend to freak out when they see a long-running query show up in monitoring tools. We've had a number of Marten users complain about the "load" that monitoring tools are reporting despite pg_sleep not doing anything, to the point that we provided an opt-out on monitoring just to eliminate the noise. This gets flagged by automated problem finders too, like Datadog's DBM and RDS Performance Insights
  • The sleeping query skews query performance stats as your average query time goes through the roof and you have to filter it out whenever you're looking at metrics or trying to setup alarms.

This PR adds a passive approach that waits for the socket to break instead. In monitoring tools this will simply show up as an idle connection. This is codepath is enabled by default, but is unsupported when:

  • Npgsql Multiplexing is enabled (not very important as multiplexing is getting removed from npgsql in v11)
  • KeepAlive is enabled on the connection string

If either case is true, it'll fall back to using the pg_sleep path.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Hawxy