-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Postresql plugin does not close connections properly #2410
Comments
I believe this is a dupe of #1977 |
actually looks slightly different on second glance.... Could you try testing with 1.2.1 ( |
I updated telegraf and restartet it. I will report the status in a few hours |
Did not solve the problem. There is still a lot of established connections. |
Yes, but from a development perspective I'm not sure what we can do besides call db.Close() (which we're doing already): https://github.com/influxdata/telegraf/blob/master/plugins/inputs/postgresql/postgresql.go#L76 Are you sure it's telegraf causing this? from your netstat output it looks like it's grafana..? |
@punkkeks could you try another thing? try specifying your connection URL as:
the reason being that we skip making a "connection pool" in that case |
grafana is just the hostname. Grafana uses a postgresql connection.. hm.. I could stop telegraf and wait for an hour and then look at the connections again. But first I will try the other connection URI |
It seems that the URI string has fixed the problem. What?! I will switch back to the old one and check if the bug occours again. |
Yep. That was it. I switched back and forth multiple times and whenver the config had the uri instead of the "old" settings, the connections were properly closed. I would suggest removing the old config format from the sample config and solely using the new one. (btw. could anyone update the readme for postgresql? There is no example config, you have to extract it from the go "source") |
@punkkeks could you do that? 🙏 , you can edit a readme from within the github web interface, it's quite easy. |
nevermind, I'm going to edit the plugin anyways, I'll do it |
It seems to be a limitation of the client library. For some reason it forces you to create a "connection pool" if you have it in that format, whereas the other format you can simply open a connection. I have no idea why, and I don't know enough about postgres connection pools to figure out a proper configuration for that. If you happen to have time to fiddle around with this code and find a solution, I'd appreciate it immensely :) https://github.com/influxdata/telegraf/blob/master/plugins/inputs/postgresql/connect.go#L93-L98 @phemmer might have better ideas than me |
I haven't used the |
@phemmer postgresql_extensible calls the same function to make a connection to db as the postgres plugin |
Thanks guys :) |
Oh, I didn't notice that it's including the |
Also I would probably leave this ticket open. While the bug may be in an external library, telegraf would need to take action to get it fixed, such as updating the library once upstream issue is resolved. Other people may also come here and look for the issue before opening a new one. Although since I don't experience the issue on my systems, it appears that it's not the format of the |
yes, we need to figure out why this is leaking connections, @punkkeks I'm going to reopen |
Okay. I'll try to provide some tcpdumps tomorrow (GMT+1) to see what's gonig wrong. |
* Add configuration docs to Postgresql input plugin Add configuration docs to PostgreSQL input plugin README (mostly from the source code) though I've not included the configuration example that seems to use all he connections on the database[1]. [1] #2410 * Fix typo in readme and sampleConfig string.
@sparrc I'll happily look into this. |
* Add configuration docs to Postgresql input plugin Add configuration docs to PostgreSQL input plugin README (mostly from the source code) though I've not included the configuration example that seems to use all he connections on the database[1]. [1] influxdata#2410 * Fix typo in readme and sampleConfig string.
* Add configuration docs to Postgresql input plugin Add configuration docs to PostgreSQL input plugin README (mostly from the source code) though I've not included the configuration example that seems to use all he connections on the database[1]. [1] influxdata#2410 * Fix typo in readme and sampleConfig string.
* Add configuration docs to Postgresql input plugin Add configuration docs to PostgreSQL input plugin README (mostly from the source code) though I've not included the configuration example that seems to use all he connections on the database[1]. [1] influxdata#2410 * Fix typo in readme and sampleConfig string.
* Add configuration docs to Postgresql input plugin Add configuration docs to PostgreSQL input plugin README (mostly from the source code) though I've not included the configuration example that seems to use all he connections on the database[1]. [1] #2410 * Fix typo in readme and sampleConfig string.
Bug report
when using the postgresql plugin and let it run for some time (1 hour should be enough) the postgresql server will claim, that there are no more free connections.
A look with netstat will confirm this (my current limit is 500 connections, all of them are in use)
Relevant telegraf.conf:
Versions
This is, at least for me, always reproducible, even after I restart postgres, telegraf or influx. None of that worked
The text was updated successfully, but these errors were encountered: