Skip to content

Comments

Feature | Fix enhanced routing ack handling.#3973

Open
mdaigle wants to merge 1 commit intodev/mdaigle/enhanced-routing-2from
dev/mdaigle/enhanced-routing-3-redo
Open

Feature | Fix enhanced routing ack handling.#3973
mdaigle wants to merge 1 commit intodev/mdaigle/enhanced-routing-2from
dev/mdaigle/enhanced-routing-3-redo

Conversation

@mdaigle
Copy link
Contributor

@mdaigle mdaigle commented Feb 20, 2026

Ports #3922 to main

Copilot AI review requested due to automatic review settings February 20, 2026 20:01
@mdaigle mdaigle closed this Feb 20, 2026
@mdaigle mdaigle reopened this Feb 20, 2026
Copy link
Contributor

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 pull request fixes the handling of enhanced routing acknowledgment in SQL Server connections. The PR ensures that enhanced routing information (which includes a database name) is only used when the server explicitly acknowledges support for the FEATUREEXT_ENHANCEDROUTINGSUPPORT feature extension. If the server doesn't acknowledge the feature or explicitly disables it, the routing information is ignored and the connection stays with the current server.

Changes:

  • Added validation logic to ignore enhanced routing info when DatabaseName is present but IsEnhancedRoutingSupportEnabled is false
  • Updated OnFeatureExtAck to process enhanced routing feature acknowledgment even during routing
  • Refactored unit tests to use a helper class pattern and cover both sync and async code paths

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Connection/SqlConnectionInternal.cs Added enhanced routing acknowledgment validation in LoginNoFailover and LoginWithFailover methods; updated OnFeatureExtAck to allow processing of enhanced routing feature
src/Microsoft.Data.SqlClient/tests/UnitTests/SimulatedServerTests/ConnectionEnhancedRoutingTests.cs Refactored tests to use TestRoutingServers helper class; converted to Theory-based tests covering sync/async paths and multiple server behaviors

$"SqlInternalConnectionTds.LoginWithFailover | " +
$"Ignoring enhanced routing info because the server did not acknowledge the feature.");
RoutingInfo = null;
continue;
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The use of continue here is inconsistent with the equivalent logic in LoginNoFailover (line 3299), which uses break. Both are functionally equivalent since RoutingInfo is set to null immediately before, but break is more explicit and clearer about the intent to exit the routing loop. Consider changing continue to break for consistency.

Suggested change
continue;
break;

Copilot uses AI. Check for mistakes.
@mdaigle mdaigle linked an issue Feb 20, 2026 that may be closed by this pull request
@mdaigle mdaigle marked this pull request as ready for review February 20, 2026 20:05
@mdaigle mdaigle requested a review from a team as a code owner February 20, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support routing to named read replicas

1 participant