[GODRIVER-508] topology.Server.update leaks time.Tickers Created: 25/Jul/18  Updated: 28/Oct/23  Resolved: 26/Jul/18

Status: Closed
Project: Go Driver
Component/s: Server Discovery and Monitoring
Affects Version/s: 0.0.9
Fix Version/s: 0.0.10

Type: Bug Priority: Major - P3
Reporter: Rikard Anglerud Assignee: Kristofer Brandow (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2018-07-25-18-16-03-809.png    

 Description   

The update method sets up two tickers, but does not stop them. This causes a memory leak.

Found while implementing a prometheus blackbox-style probe. I've got a small patch I'll send as a github PR. Below is my probe running without it for a few hours, then with it.

 



 Comments   
Comment by Kristofer Brandow (Inactive) [ 26/Jul/18 ]

Thanks again for the bug report and the pull request!

Comment by Githook User [ 26/Jul/18 ]

Author:

{'name': 'Rikard Anglerud', 'email': 'Rikard.Anglerud@man.com'}

Message: GODRIVER-508 - call Stop() on heartbeatTicker and rateLimitr

This should fix a memory leak in topology.Server's update()
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/06a71c7445d6ee35d0cb66dcc6dba94edf043667

Comment by Rikard Anglerud [ 25/Jul/18 ]

Thank you - I've submitted https://github.com/mongodb/mongo-go-driver/pull/78

Comment by Kristofer Brandow (Inactive) [ 25/Jul/18 ]

Okay, great. I'll keep an eye out for the pull request.

Comment by Rikard Anglerud [ 25/Jul/18 ]

Those are the ones, yep.

Comment by Kristofer Brandow (Inactive) [ 25/Jul/18 ]

Hi ranglerud,

Thanks for the bug report. Are these the timers you are referring to? 

https://github.com/mongodb/mongo-go-driver/blob/eecffe0eec1ec89b01fcb17f288d59dfde0ab9e8/core/topology/server.go#L252-L253

--Kris

Generated at Thu Feb 08 08:34:21 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.