Support new ReadPreference semantics, deprecate SlaveOK (JAVA-428)

[JAVA-450] Implement Proposed Bucketing Behavior for MongoDB 2.0 Replica Sets Created: 18/Oct/11  Updated: 19/Oct/16  Resolved: 07/Mar/12

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

Type: Sub-task Priority: Major - P3
Reporter: Brendan W. McAdams Assignee: Antoine Girbal
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible

 Description   

The first version of 2.0 Replica Set Support doesn't implement the proposed "ping bucket" code. We should evaluate implementing this for a future release.



 Comments   
Comment by Jeffrey Yemin [ 07/Mar/12 ]

We've decided against the bucking algorithm in favor of the algorithm already implemented by the Java driver.

Comment by Brendan W. McAdams [ 16/Dec/11 ]

New system for choosing secondaries, as outlined in the docs for the
ReadPreference/WriteConcern spec.

setReadPreference(secondary)

Implementation detail: automatically create a set of buckets that grow
exponentially. Pick secondaries randomly from nodes in the nearest bucket.
Use the “ping” command for testing ping times. Do this every five seconds,
using a separate socket, with very low timeouts.
BucketNumber of nodes1 (0 - 10ms)22 (10 - 100ms)13 (100 - 1000ms)3

In this case, we’d pick randomly from the nodes in the 0-10ms bucket. If
users need more sophisticated read preferences, let them use tags.

If no secondary is available, fall back on reading from the primary.

In Java, we’ll probably want to add a ReadPreference class (like
WriteConcern).

Eventually, there should be a “secondaryOnly” option, too, that will only
read from a secondary and return an error if only the primary is available.
This is not necessary for 2.0, though.

Comment by Antoine Girbal [ 18/Oct/11 ]

I dont quite get this bucketing system.
Are the ranges always the same?
If you have 1 server at 9ms and 3 servers at 12ms, will it use only the former?
The current driver behavior of "group within a certain latency delay of closest server" seems like a better heuristic to use all servers within the closest datacenter.
The latency delay can even be relative to the latency.

Comment by Brendan W. McAdams [ 18/Oct/11 ]

New guidelines for choosing a secondary as outlined in the spec for the new 2.0 options:

setReadPreference(secondary)
Implementation detail: automatically create a set of buckets that grow exponentially. Pick secondaries randomly from nodes in the nearest bucket. Use the “ping” command for testing ping times. Do this every five seconds, using a separate socket, with very low timeouts.

Bucket Number of nodes
1 (0 - 10ms) 2
2 (10 - 100ms) 1
3 (100 - 1000ms) 3
In this case, we’d pick randomly from the nodes in the 0-10ms bucket. If users need more sophisticated read preferences, let them use tags.

If no secondary is available, fall back on reading from the primary.

In Java, we’ll probably want to add a ReadPreference class (like WriteConcern).

Eventually, there should be a “secondaryOnly” option, too, that will only read from a secondary and return an error if only the primary is available. This is not necessary for 2.0, though.

Comment by Antoine Girbal [ 18/Oct/11 ]

what is the ping bucket system?
Is that a new feature that was decided on for all drivers?
I thought we were going to use tagging instead.

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