1 / 1
May 2024

I am restricting the number of connections a client can make as follows:

client_options.max_pool_size = Some(20); client_options.min_pool_size = Some(10);

however I was getting this weird error when running my code (removed company domain name):

Failed audit entry: Error { kind: ServerSelection { message: "Server selection timeout: None of the available servers suitable for criteria ReadPreference(Primary). Topology: { Type: ReplicaSetNoPrimary, Set Name: auditnpdrs, Max Set Version: 5, Max Election ID: 7fffffff0000000000000004, Servers: [ { Address: mgdb-audit-npd1-1:27060, Type: Unknown, Error: Kind: I/O error: timed out, labels: {} }, { Address: mgdb-audit-npd2-1.cisco.com:27060, Type: Unknown, Error: Kind: I/O error: timed out, labels: {} }, { Address: mgdb-audit-npd3-1:27060, Type: RsSecondary, Average RTT: 2.036058163s, Last Update Time: 2024-05-23 17:44:59.017 +00:00:00, Max Wire Version: 17, Min Wire Version: 0, Replica Set Name: auditnpdrs, Replica Set Version: 5 } ] }" }, labels: {}, wire_version: None, source: None }

Ops team said I was creating over 3k connections to the server, which is over the 1k limit they set:

{"t":{"$date":"2024-05-23T11:23:46.755-07:00"},"s":"I", "c":"-", "id":4760300, "ctx":"conn1069706","msg":"Gathering currentOp information, operation of size {size} exceeds the size limit of {limit} and will be truncated.","attr":{"size":3232,"limit":1000}} {"t":{"$date":"2024-05-23T11:23:47.358-07:00"},"s":"I", "c":"-", "id":4760300, "ctx":"conn313701","msg":"Gathering currentOp information, operation of size {size} exceeds the size limit of {limit} and will be truncated.","attr":{"size":3299,"limit":1000}} {"t":{"$date":"2024-05-23T11:23:53.358-07:00"},"s":"I", "c":"-", "id":4760300, "ctx":"conn313701","msg":"Gathering currentOp information, operation of size {size} exceeds the size limit of {limit} and will be truncated.","attr":{"size":3222,"limit":1000}}

I am on

mongodb = {version ="2.8.1", features = ["bson-chrono-0_4"]}

and using tokio. I am not running any of the mongo code in a timeout per the suggestion on the GitHub. I am cloning the MongoDatabase quite often, since I setup the options once, and then create multiple commit “jobs” by invoking tokio::spawn.

I want help figuring out if this is an issue with my code, or the mongo driver, or something else.