Skip to content

RUST-2179 Ignore whether nodes are data-bearing when directConnection is true #1334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/sdam/description/topology/server_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,12 @@ impl TopologyDescription {
SelectionCriteria::Predicate(ref filter) => self
.servers
.values()
.filter(|s| s.server_type.is_data_bearing() && filter(&ServerInfo::new_borrowed(s)))
.filter(|s| {
// If we're direct-connected or connected to a standalone, ignore whether the
// single server in the topology is data-bearing.
(self.topology_type == TopologyType::Single || s.server_type.is_data_bearing())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GetMore operation sets its selection criteria to a predicate, which meant that a direct connection to a hidden replica set member (which the driver gives server type RsOther) couldn't be selected here because it's not considered data-bearing. The fix here is to ignore whether a server is data-bearing if it's the only one in the topology. I didn't have much spec guidance to go off of here because, as far as I can tell, the predicate selection criteria variant is a rust-driver-specific thing. However, this server selection spec section indicates that the lone server in a single topology should always be selected.

It does still seem reasonable to filter out non-data-bearing servers when there are multiple servers in a topology so that, e.g., an arbiter isn't selected when a primary or secondary is also available.

&& filter(&ServerInfo::new_borrowed(s))
})
.collect(),
};

Expand Down