[JAVA-3197] Non Blocking Secondary Reads with 4.0 Created: 11/Feb/19  Updated: 11/Sep/19  Resolved: 15/Feb/19

Status: Closed
Project: Java Driver
Component/s: Query Operations
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Satish Anupindi Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

RHEL 7.4 Enterprise MongoDB


Attachments: PNG File Screen Shot 2019-02-08 at 1.18.13 PM.png    

 Description   

I have questions about the non-blocking secondary reads with MongoDB 4.0+

  1. We have a primary and 3 secondaries. When we set the read preference as "secondaryPreferred", does the client choose only one secondary amongst the 3 secondaries and direct its reads to that secondary? Or does it load balance across 2ndaries?
  1. I am seeing read requests coming into one secondary even when I leave the read preference as default i.e. Primary. I see the same behavior when I set the read preference as 2ndar preferred. I have attached screenshot of the document metrics and OpCounter stats (from Ops Mgr) when we have the default primary read pref. Does it make sense? Or am I doing something incorrect?


 Comments   
Comment by Jeffrey Yemin [ 15/Feb/19 ]

Hi satish.anupindi@aexp.com

  1. The driver load balances all available secondaries. If no secondaries are available, it directs all requests to the primary.
  2. It's possible that it's a driver bug, but if so this would be the first report. A few things to check:
    1. Enable DEBUG logging in the driver for the org.mongodb.driver.protocol component.  That will log messages like: "Sending command '%s' with request id %d to database %s on connection [%s] to server %s" so you can see where requests are being routed
    2. Check the server logs to see where requests are actually originating.
    3. Check your MongoClient settings to make sure you're not accidentally leaving the read preference as non-primary.  Note also that the read preference can be change per MongoCollection or MongoDatabase, so it's possible that the primary read preference is being overridden somewhere else in your application.

 

Just to let you know this project is for Java driver bugs or feature requests. The best place for questions regarding MongoDB usage or the Java driver specifics is the mongodb-user mailing list or stackoverflow as you will reach a broader audience there. If your business requires an answer from MongoDB within a time frame then we do offer production support.

If you do follow up via one of the options above please post a link and I will follow the conversation there.

Comment by Satish Anupindi [ 11/Feb/19 ]

Check the OP counter and doc metrics on mrerh7mongodb2.phx.lab.aexp.com. This is when having default primary read preference

Generated at Thu Feb 08 08:59:01 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.