Skip to content

Commit 295c958

Browse files
committed
Add logs to show deprioritization
1 parent 6eb7a22 commit 295c958

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/client.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,15 @@ impl Client {
497497
} else {
498498
criteria
499499
};
500+
501+
if operation_name == "insert" || operation_name == "find" {
502+
let servers = &state.description.servers;
503+
for (address, description) in servers {
504+
dbg!("address: {}", address);
505+
dbg!("type: {}", description.server_type);
506+
}
507+
}
508+
500509
let result = server_selection::attempt_to_select_server(
501510
effective_criteria,
502511
&state.description,

src/client/executor.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ impl Client {
318318
.and_then(|s| s.transaction.pinned_mongos())
319319
.or_else(|| op.selection_criteria());
320320

321+
if op.name() == "insert" || op.name() == "find" {
322+
let first_server = retry.as_ref().map(|r| &r.first_server);
323+
dbg!("deprioritized: {}", &first_server);
324+
}
325+
321326
let (server, effective_criteria) = match self
322327
.select_server(
323328
selection_criteria,

src/sdam/description/topology/server_selection.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ pub(crate) fn attempt_to_select_server<'a>(
6161
servers: &'a HashMap<ServerAddress, Arc<Server>>,
6262
deprioritized: Option<&ServerAddress>,
6363
) -> Result<Option<SelectedServer>> {
64+
let log = deprioritized.is_some();
65+
6466
let mut in_window = topology_description.suitable_servers_in_latency_window(criteria)?;
67+
if log {
68+
dbg!("in window: {}", &in_window);
69+
}
70+
6571
if let Some(addr) = deprioritized {
6672
if in_window.len() > 1 {
6773
in_window.retain(|d| &d.address != addr);

0 commit comments

Comments
 (0)