[CXX-1208] Timeout 10s for queries when shutting down one server of replicaset Created: 28/Jan/17  Updated: 27/Oct/23  Resolved: 28/Jan/17

Status: Closed
Project: C++ Driver
Component/s: None
Affects Version/s: 3.1.1
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Denis Bip Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux, Debian 8, C driver 1.5.3



 Description   

I have replicaset with several servers and when I shut down one of secondary server I've got timeout of read queries 10 seconds. Client has default read_preference (as far as I know it's read from primary). Why driver wait for secondary when its not needed by settings?



 Comments   
Comment by David Golden [ 28/Jan/17 ]

I'm going to close this ticket, as you've got the workaround you need, but feel free to ask more questions even after it's closed if you'd like.

Comment by David Golden [ 28/Jan/17 ]

Here's a blog post with the gory details: Server Discovery and Monitoring In Next Generation MongoDB Drivers

Comment by Denis Bip [ 28/Jan/17 ]

Thank you very much for explain! Now I understand how it works, if you can give me more information on Monday - that will be very nice, thanks)

Comment by David Golden [ 28/Jan/17 ]

I'm happy to explain more on Monday if you'd like, but briefly so you don't spend too much time on this:

  • mongocxx::client is single-threaded, and scans all servers at startup and once a minute. The 10 seconds you're seeing is the connection timeout on the socket to the down server.
  • mongocxx::pool is multi-threaded, and maintains a thread per server in the background to do continuous monitoring.

For replica sets, unless you're in an extremely resource limited environment, pool is the best choice. We have some tickets to make this more explicit in our documentation.

Comment by Denis Bip [ 28/Jan/17 ]

With mongocxx::pool the problem seems to go away, but interesting that mongocxx::client works with delay even I block client-server ip at one of Arbiter-server...continue testing...

Comment by Denis Bip [ 28/Jan/17 ]

I'm using mongocxx::client. In short it's very simple code, like in examples, just create client and do the query (aggregate with mongocxx::pipeline)

Comment by David Golden [ 28/Jan/17 ]

Hi. It would be really helpful if you could give us an SSCCE.

Regardless, my first diagnostic question is whether you're using mongocxx::client or mongocxx::pool? In pretty much any non-toy case (i.e. with a replica set), you should be using the pool.

Generated at Wed Feb 07 22:01:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.