-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.15.0, 2.15.1, 2.16.0, 2.16.1
-
Component/s: Connectivity
-
None
Summary
I have a C# program, basically, it connects to all mongo instances, and get the version information. to ensure that the mongodb version is as expected. The program works smoothly for driver version 2.14.1 for long time. Recently, I upgrade Mongo C# driver version from 2.14.1 to 2.15.0 and above, and program throw error below:
processing: 328 of 452
error: System.OutOfMemoryException: type is “System.OutOfMemoryException”
at System.Threading.Thread.StartInternal(IPrincipal principal, StackCrawlMark& stackMark)
at System.Threading.Thread.Start(StackCrawlMark& stackMark)
at System.Threading.Thread.Start()
at MongoDB.Driver.Core.Servers.RoundTripTimeMonitor.Start()
at MongoDB.Driver.Core.Servers.ServerMonitor.Initialize()
at MongoDB.Driver.Core.Servers.DefaultServer.InitializeSubClass()
at MongoDB.Driver.Core.Servers.Server.Initialize()
at MongoDB.Driver.Core.Clusters.MultiServerCluster.Initialize()
at MongoDB.Driver.ClusterRegistry.CreateCluster(ClusterKey clusterKey)
at MongoDB.Driver.ClusterRegistry.GetOrCreateCluster(ClusterKey clusterKey)
at MongoDB.Driver.MongoClient..ctor(MongoClientSettings settings)
at MongoDB.Driver.MongoClient..ctor(MongoUrl url)
at Ctrip.DBConfig.Business.MongoCheckVersion.check()
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
2.15.0, 2.15.1, 2.16.0 and 2.16.1 work smoothly for 2.14.1 and below.
How to Reproduce
List<MongoClusterInfo> MongoClusterList = SQLMonitorV3.getMongoClusterList();
for (int i = 0; i < MongoClusterList.Count; i++)
{
string cluster_name = MongoClusterList[i].cluster_name;
string env_type = MongoClusterList[i].env_type;
string cluster_type = MongoClusterList[i].cluster_type;
int status = MongoClusterList[i].status;
int is_dr = MongoClusterList[i].is_dr;
string user = "username";
string pwd = "password";
string connString = "mongodb://" + user + ":" + pwd + "@";
Console.WriteLine("processing:" + "\t" + i.ToString() + " of " + MongoClusterList.Count.ToString());
if (cluster_type.Equals("sharding"))
{
List<MongoInstanceInfo> MongoInstanceList = SQLMonitorV3.getMongoInstanceList(cluster_name + "mongos");
for (int j = 0; j < MongoInstanceList.Count; j++)
connString = connString.Substring(0, connString.Length - 1);
connString += "/?authSource=admin";
}
else
{
List<MongoInstanceInfo> MongoInstanceList = SQLMonitorV3.getMongoInstanceList(cluster_name);
for (int j = 0; j < MongoInstanceList.Count; j++)
connString = connString.Substring(0, connString.Length - 1);
connString += "/admin" + "?replicaSet=" + cluster_name;
}
try
{
var mongourl = new MongoUrl(connString);
MongoClient client = new MongoClient(mongourl);
var db = client.GetDatabase("admin");
BsonDocument result = db.RunCommand<BsonDocument>(new BsonDocument("buildInfo", 1));
string version = (string)result.GetValue("version");
string allocator = (string)result.GetValue("allocator");
if (!(version.Equals("4.0.19") ||
version.Equals("4.2.17") ||
version.Equals("4.2.19") ||
version.StartsWith("4.2.") ||
version.Equals("4.2.18")))
if (!allocator.Equals("tcmalloc"))
}
catch (Exception e)
}//end of for
Steps to reproduce. If possible, please include a Short, Self Contained, Correct (Compilable), Example.
- ensure we have more than 400 mongo instances to check.
- Run the above program, it will throw out error when in around iteration 330.
- Only the iteration number counts. I skip some iterations, and it will hit error later
- Note, once I revert driver back to 2.14.1. it works fine.
Additional Background
Please provide any additional background information that may be helpful in diagnosing the bug.