Skip to content

Conversation

matthewdale
Copy link
Collaborator

GODRIVER-3648

Summary

Remove the default case from the select statement in Topology.selectServerFromSubscription, making the loop block until there is a topology change.

Background & Motivation

A bug was introduced in #1515 that makes the Topology.selectServerFromSubscription loop non-blocking, resulting in a tight loop when there are no selectable servers.

@matthewdale matthewdale requested a review from a team as a code owner September 26, 2025 19:22
@matthewdale matthewdale added bug review-priority-normal Medium Priority PR for Review: within 1 business day labels Sep 26, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where server selection enters a tight loop when no selectable servers are available by removing the default case from a select statement to make topology updates blocking.

  • Removes the default case from the select statement in Topology.selectServerFromSubscription
  • Changes the server selection loop from non-blocking to blocking behavior
  • Prevents CPU-intensive tight looping when waiting for topology changes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

API Change Report

No changes found!

Copy link
Contributor

mongodb-drivers-pr-bot bot commented Sep 26, 2025

🧪 Performance Results

Commit SHA: 768bf6d

There were no significant changes to the performance to report for version 68d6eaba504edc00072d9fbb.

Benchmark Measurement % Change Patch Value Stable Region H-Score Z-Score

For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch.

@matthewdale matthewdale changed the base branch from master to release/2.3 September 26, 2025 19:33
@matthewdale matthewdale force-pushed the godriver3648-fix-select-server-blocking branch from d91361f to 768bf6d Compare September 26, 2025 19:34
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need a test case for the change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, it would be a good idea to add a test. I'll try to find a sensible assertion we can make to check that it doesn't enter a busy wait.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug review-priority-normal Medium Priority PR for Review: within 1 business day
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants