You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we're using the metricbeat sql module to gather some metrics. During Downtime of our Database, I observed slowly increasing memory consumption from metricbeat.
I tried to reproduce this with the following metricbeat config with a non-existent Database:
Steps to Reproduce:
Create SQL Config pointing to a non-existent Database
Using example config from the metricbeat reference:
metricbeat.modules:
- module: sql
metricsets:
- query
period: 10s
hosts: ["root:root@tcp(localhost:3306)/ps"]
driver: "mysql"
sql_query: "SHOW GLOBAL STATUS LIKE 'Innodb_system%'"
sql_response_format: variables
Let it run for a few minutes/hours - While metricbeat was running, I could see a steady increase in memory consumption from metricbeat.
I restarted metricbeat with the httpprof parameter and could observe that many database/sql.(*DB).connectionOpener goroutines are being created.
there is a check to test if the connection to the database works and if not, returns an error - but in case there is an error, the Database Object is never closed and leaking the goroutine.
@simioa thanks for reporting this! I think you are right, NewDBClient should close the connection if it fails to ping. Would you like to open a PR with your fix?
Hello,
we're using the metricbeat sql module to gather some metrics. During Downtime of our Database, I observed slowly increasing memory consumption from metricbeat.
I tried to reproduce this with the following metricbeat config with a non-existent Database:
Using example config from the metricbeat reference:
I restarted metricbeat with the httpprof parameter and could observe that many
database/sql.(*DB).connectionOpener
goroutines are being created.With debug=2
After some debugging I think I figured out what happens.
In
beats/metricbeat/helper/sql/sql.go
Lines 53 to 56 in 651a2ad
To test my assumption, I replaced the code
with
After replacing the code, I could not observe further memory growth or goroutine creations.
Can you please check if my assumption is correct or if this is even a bug?
The text was updated successfully, but these errors were encountered: