[CSHARP-4007] maxIdleTimeMS does not work as expect Created: 05/Jan/22  Updated: 27/Oct/23  Resolved: 13/Jan/22

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

Type: Improvement Priority: Major - P3
Reporter: A B Assignee: Robert Stam
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

In my project, I defined connectionString consists of MaxIdleTimeMS Property but some time max connection Idle time out does not work correctly as expect.

below is describle of test pattern i have executed:

context:

current connections number: 1
when I setting MaxIdleTimeMS=0 and operation screen to establish connection to DB

the curren connections number still 1 (as expect)

when I setting  MaxIdleTimeMS=5 and operation screen to establish connection to DB

the curren connections number : 2 (increase 1) 
but I have to waiting about 10 minutes for connection close (current connections number:1)

I don't know whether somewhere in C# driver source code has overwrite MaxIdleTimeMS value or not but, I can't accurately adjust the MaxIdleTimeMS number as expect.

If that is about my mistake, can someone give me some comment pls?

 



 Comments   
Comment by A B [ 12/Jan/22 ]

@Robert

I understand.

Thank you very much for your quick confirmation.

 

Comment by Robert Stam [ 06/Jan/22 ]

I have tried to reproduce what you have reported and all appears to be working properly, but some explanations are in order.

  1. The driver keeps 2 dedicated connections to each server open permanently. One is used to monitor the status of the server, and the other is used to measure the network round trip time to the server
  2. Idle connections are removed from the connection pool via a background maintenance task that runs about once per minute

So it could take up to a minute for an idle connection to be removed from the connection pool. However, even though an idle connection might not be removed from the connection pool for up to a minute, an idle connection will never be used by the application. If the application needs a connection from the connection pool only non-idle connections will be returned.

Comment by A B [ 06/Jan/22 ]

@Robert

I'm using MongoDB.Driver.Core, Version=2.13.2.0.

I determine the current number connections by executing db.ServerStatus() command in database console.

 

Comment by Robert Stam [ 05/Jan/22 ]

In order to investigate your questions please provide the following information:

  • What version of the C# driver are you using?
  • How are you determining the number of current connections?
Generated at Wed Feb 07 21:46:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.