[CDRIVER-799] Scanner must obey connectTimeoutMS Created: 12/Aug/15  Updated: 19/Oct/16  Resolved: 17/Aug/15

Status: Closed
Project: C Driver
Component/s: libmongoc
Affects Version/s: 1.2-beta0
Fix Version/s: 1.2-beta1

Type: Bug Priority: Major - P3
Reporter: A. Jesse Jiryu Davis Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Currently the scanner waits serverSelectionTimeoutMS to connect to all servers and receive ismaster responses. This doesn't match the spec:

The socket used to check a server MUST use the same connectTimeoutMS as regular sockets. Multi-threaded clients SHOULD set monitoring sockets' socketTimeoutMS to the connectTimeoutMS.

When a client waits for a server to respond to a connection, the client does not know if the server will respond eventually or if it is down. Users can help the client guess correctly by supplying a reasonable connectTimeoutMS for their network: on some networks a server is probably down if it hasn't responded in 10 ms, on others a server might still be up even if it hasn't responded in 10 seconds.

The socketTimeoutMS, on the other hand, must account for both network latency and the operation's duration on the server. Applications should typically set a very long or infinite socketTimeoutMS so they can wait for long-running MongoDB operations.

Multi-threaded clients use distinct sockets for monitoring and for application operations. A socket used for monitoring does two things: it connects and calls ismaster. Both operations are fast on the server, so only network latency matters. Thus both operations SHOULD use connectTimeoutMS, since that is the value users supply to help the client guess if a server is down, based on users' knowledge of expected latencies on their networks.

serverSelectionTimeoutMS on the other hand expresses the user's expectation of how long an election or other topology change might take. The two knobs should be kept distinct.

The selection time for a single-threaded client with serverSelectionTryOnce "on" (the default) should be affected by connectTimeoutMS, not serverSelectionTimeoutMS, but currently it's the opposite.



 Comments   
Comment by Githook User [ 23/Aug/16 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-1473 delete flakey timeout test

This test was to prove the scanner obeys connectTimeoutMS (CDRIVER-799),
but test_select_after_try_once does that more simply and reliably.

Also deals with CDRIVER-1305.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/0402b055070d76b6ffe830dd26a1c4b4299085e4

Comment by Githook User [ 17/Aug/15 ]

Author:

{u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}

Message: CDRIVER-799 use connecttimeoutms for ismaster checks

Currently the scanner waits serverSelectionTimeoutMS to connect to all servers
and receive ismaster responses. This doesn't match the spec:

"The socket used to check a server MUST use the same connectTimeoutMS as
regular sockets. Multi-threaded clients SHOULD set monitoring sockets'
socketTimeoutMS to the connectTimeoutMS."
Branch: 1.2.0-dev
https://github.com/mongodb/mongo-c-driver/commit/98f5fdaac04fa562791a6284a93ec943014d59c3

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