Feature | Fix enhanced routing ack handling.#3973
Feature | Fix enhanced routing ack handling.#3973mdaigle wants to merge 1 commit intodev/mdaigle/enhanced-routing-2from
Conversation
There was a problem hiding this comment.
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
DatabaseNameis present butIsEnhancedRoutingSupportEnabledis false - Updated
OnFeatureExtAckto 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; |
There was a problem hiding this comment.
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.
| continue; | |
| break; |
Ports #3922 to main