mirror of
https://github.com/prometheus/node_exporter.git
synced 2024-12-28 23:19:46 -08:00
Fix timer GC delays in the Linux filesystem collector (#2169)
Use `time.NewTimer()` and explicit `Stop()` to avoid memory bloat / GC problems with `time.After()` in the Linux filesystem collector timeout handling. Signed-off-by: bawenmao <bawenmao@sogou-inc.com>
This commit is contained in:
parent
863e737538
commit
fbc23548b9
|
@ -122,10 +122,12 @@ func (c *filesystemCollector) GetStats() ([]filesystemStats, error) {
|
||||||
// then the watcher does nothing. If instead the timeout is reached, the
|
// then the watcher does nothing. If instead the timeout is reached, the
|
||||||
// mount point that is being watched is marked as stuck.
|
// mount point that is being watched is marked as stuck.
|
||||||
func stuckMountWatcher(mountPoint string, success chan struct{}, logger log.Logger) {
|
func stuckMountWatcher(mountPoint string, success chan struct{}, logger log.Logger) {
|
||||||
|
mountCheckTimer := time.NewTimer(*mountTimeout)
|
||||||
|
defer mountCheckTimer.Stop()
|
||||||
select {
|
select {
|
||||||
case <-success:
|
case <-success:
|
||||||
// Success
|
// Success
|
||||||
case <-time.After(*mountTimeout):
|
case <-mountCheckTimer.C:
|
||||||
// Timed out, mark mount as stuck
|
// Timed out, mark mount as stuck
|
||||||
stuckMountsMtx.Lock()
|
stuckMountsMtx.Lock()
|
||||||
select {
|
select {
|
||||||
|
|
Loading…
Reference in a new issue