Skip to content

Commit 68ea167

Browse files
authored
Fix a connection leak (#902)
The leak was introduced in PR#882 Signed-off-by: Christian Albrecht <cal@albix.de> Co-authored-by: Christian Albrecht <christian.albrecht@akquinet.de>
1 parent a181fba commit 68ea167

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

Diff for: collector/collector.go

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ func (p PostgresCollector) Collect(ch chan<- prometheus.Metric) {
173173
level.Error(p.logger).Log("msg", "Error opening connection to database", "err", err)
174174
return
175175
}
176+
defer p.instance.Close()
176177

177178
wg := sync.WaitGroup{}
178179
wg.Add(len(p.Collectors))

Diff for: collector/probe.go

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func (pc *ProbeCollector) Collect(ch chan<- prometheus.Metric) {
8181
level.Error(pc.logger).Log("msg", "Error opening connection to database", "err", err)
8282
return
8383
}
84+
defer pc.instance.Close()
8485

8586
wg := sync.WaitGroup{}
8687
wg.Add(len(pc.collectors))

0 commit comments

Comments
 (0)