-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve data directory detection #454
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not tested this yet. Opening for feedback on the approach first.
d0bab37
to
ce59b50
Compare
Currently, for gathering system stats on self-hosted systems, we look up the current working directory of the postmaster process. This usually works, but if customers have an unusual configuration, it can find the wrong directory. Instead, use the current method only as a fallback, and look at the data_directory setting instead. This is readable with pg_read_all_settings (part of pg_monitor), so it should be accessible to us in most configurations.
ce59b50
to
06ba25a
Compare
I'm curious, did you run an end to end test with this? Wondering whether we should do a full test in a clean container/VM before we merge, or whether we feel its been sufficiently tested. |
@lfittl I've instrumented the code to verify that the correct setting is picked up, but I have not done an end-to-end test. I'm trying to figure out something that would do the wrong thing on |
Hmm, so I'm actually unable to reproduce the problem. If I start |
I wonder if one way to reproduce it could be to have multiple Postgres installations? i.e. if the Postgres PID search in https://github.com/pganalyze/collector/blob/main/helper/main.go#L22 gets the wrong process, it would lead to the detected data directory being incorrect. |
Oh good point. I'll try that. |
Okay, confirmed that situation can cause bogus reporting on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Some small remaining comments, but looks ready to merge overall.
And thanks for doing the extra testing!
Currently, for gathering system stats on self-hosted systems, we look
up the current working directory of the postmaster process. This
usually works, but if customers have an unusual configuration, it can
find the wrong directory.
Instead, use the current method only as a fallback, and look at the
data_directory setting instead. This is readable with
pg_read_all_settings (part of pg_monitor), so it should be accessible
to us in most configurations.