[CSHARP-4513] Problem with MonitorServer heartbeat threads. Created: 02/Feb/23 Updated: 07/Feb/23 Resolved: 07/Feb/23 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Semyon Pivovarov | Assignee: | James Kovacs |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Documentation Changes Summary: | 1. What would you like to communicate to the user about this feature? |
||||||||||||||||
| Description |
Summary:When you once created a client and created a connection to one server/cluster the thread that performs heartbeat (that lives in MongoDB.Driver.Core.Servers.MonitorServer class) will be working all the time before the application stop. Version to reproduce:From 2.15.0 (thread was added in https://jira.mongodb.org/browse/CSHARP-3761) to the latest (2.19.0). How to Reproduce:
Additional Background:That's how look threads list in our application after some time, there are 300+ threads created by MonitorServer and they never die. A lot of connections exist which never close.
|
| Comments |
| Comment by James Kovacs [ 07/Feb/23 ] |
|
Hi, Simon, Thank you for reporting this issue. Unfortunately the fix is not as straightforward as you describe. If you create multiple MongoClient instances using the same (or similar) connection strings (determined by matching ClusterKey), they use the same underlying cluster and connection pools. Disposing one MongoClient instance could break other MongoClient instances. There is an additional race condition that occurs when you dispose of a Cluster and then create a new one with the same ClusterKey. I have closed this issue as a duplicate of CSHARP-3431, which is an existing ticket to make MongoClient be disposable. Please follow that ticket for updates. Note that this is a breaking change and is planned for the 3.0 release of the driver. Sincerely, |
| Comment by Esha Bhargava [ 03/Feb/23 ] |
|
semyon@365scores.com Thank you for reporting this issue. We'll look into it and get back to you soon. |
| Comment by Semyon Pivovarov [ 02/Feb/23 ] |
|
Created PR with suggestions to fix: https://github.com/mongodb/mongo-csharp-driver/pull/1018 |