[CSHARP-2665] System.TimeoutException:“A timeout occured after 30000ms selecting a server using CompositeServerSelector Created: 11/Jul/19  Updated: 27/Oct/23  Resolved: 23/Jul/19

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 2.8.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: ding songjie Assignee: Scott L'Hommedieu (Inactive)
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

asp net core 2.2 vs 2017 windows 10



 Description   

  I was Running a mongodb cluster with 1 primary and 2 secondry , and the auth was turned off .

  If i use this connection "mongodb://192.168.0.243:27017" ,it works fine , but if i use this connection "mongodb://192.168.0.243:27017,192.168.0.242:27017,192.168.0.246:27017" ,it throw a timeout exception .
Exception details :
system.TimeoutException
HResult=0x80131505
Message=A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector

{ AllowedLatencyRange = 00:00:00.0150000 }

}. Client view of cluster state is { ClusterId : "1", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: "

{ ClusterId : 1, EndPoint : "10.36.0.4:27017" }

", EndPoint: "10.36.0.4:27017", State: "Disconnected", Type: "Unknown", LastUpdateTimestamp: "2019-07-11T10:05:57.1551274Z" }, { ServerId: "

{ ClusterId : 1, EndPoint : "10.39.0.5:27017" }

", EndPoint: "10.39.0.5:27017", State: "Disconnected", Type: "Unknown", LastUpdateTimestamp: "2019-07-11T10:05:57.1550598Z" }, { ServerId: "

{ ClusterId : 1, EndPoint : "10.42.0.2:27017" }

", EndPoint: "10.42.0.2:27017", State: "Disconnected", Type: "Unknown", LastUpdateTimestamp: "2019-07-11T10:05:57.1551144Z" }] }.
Source=MongoDB.Driver.Core
StackTrace:
at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)
at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)
at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken)
at MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken)
at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken)
at MongoDB.Driver.MongoClient.AreSessionsSupported(CancellationToken cancellationToken)
at MongoDB.Driver.OperationExecutor.StartImplicitSession(CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSession[TResult](Func`2 func, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.BulkWrite(IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionBase`1.<>c_DisplayClass64_0.<InsertOne>b_0(IEnumerable`1 requests, BulkWriteOptions bulkWriteOptions)
at MongoDB.Driver.MongoCollectionBase`1.InsertOne(TDocument document, InsertOneOptions options, Action`2 bulkWrite)
at MongoDB.Driver.MongoCollectionBase`1.InsertOne(TDocument document, InsertOneOptions options, CancellationToken cancellationToken)
at Comteck_k8s_ha_test_web.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env) in C:\Users\Admin\source\repos\test\Startup.cs:line 75
 



 Comments   
Comment by Scott L'Hommedieu (Inactive) [ 23/Jul/19 ]

Hi 377973147@qq.com
This behavior is not ideal but it is expected behavior based on the driver spec. There is ongoing investigation into how we may be able to improve this behavior natively with in the server and drivers.

This issue is also detailed here
It is a byproduct the SDAM spec that is expressed here

Importantly:

This spec requires clients to connect to the hostnames listed in the ismaster response. Furthermore, if the response is from a primary, the client MUST remove all hostnames not listed
...
Thus, replica set members must be reachable from the client by the hostnames listed in the replica set config.

There is currently no change suitable in the driver alone to remedy this issue. We will continue to pursue improvement in coordination with the server through SERVER-36603

Generated at Wed Feb 07 21:43:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.