-
Notifications
You must be signed in to change notification settings - Fork 437
Fixed session recovery for Azure SQL DB in redirect mode connected with AAD auth #2668
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
divang
merged 11 commits into
main
from
user/divang/connection_resiliency_fed_auth_issue
Jun 13, 2025
Merged
Fixed session recovery for Azure SQL DB in redirect mode connected with AAD auth #2668
divang
merged 11 commits into
main
from
user/divang/connection_resiliency_fed_auth_issue
Jun 13, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…nection to resolve Fed auth connection resiliency issue
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2668 +/- ##
============================================
+ Coverage 51.62% 51.81% +0.18%
- Complexity 4006 4022 +16
============================================
Files 147 147
Lines 33804 33802 -2
Branches 5652 5649 -3
============================================
+ Hits 17453 17516 +63
+ Misses 13888 13811 -77
- Partials 2463 2475 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…connection. In next reconnect attempt, driver try with correct end point.
…hoice to take decision on connection termination. If endpoint is routed then no need to terminate the current connection.
ADO pipeline run |
David-Engel
reviewed
May 23, 2025
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Outdated
Show resolved
Hide resolved
….java Co-authored-by: David Engel <davidengel@microsoft.com>
machavan
approved these changes
Jun 13, 2025
Ananya2
approved these changes
Jun 13, 2025
divang
added a commit
that referenced
this pull request
Jun 13, 2025
…th AAD auth (#2668) * In case of federated authentication request, do not terminate the connection to resolve Fed auth connection resiliency issue * In place of serverSupportsDNSCaching, routingInfo value is a better choice to take decision on connection termination. If endpoint is routed then no need to terminate the current connection. * Added mock test for connectionReconveryCheck() method --------- Co-authored-by: Divang Sharma <divangsharma@microsoft.com> Co-authored-by: David Engel <davidengel@microsoft.com>
divang
added a commit
that referenced
this pull request
Jun 13, 2025
…th AAD auth (#2668) * In case of federated authentication request, do not terminate the connection to resolve Fed auth connection resiliency issue * In place of serverSupportsDNSCaching, routingInfo value is a better choice to take decision on connection termination. If endpoint is routed then no need to terminate the current connection. * Added mock test for connectionReconveryCheck() method --------- Co-authored-by: Divang Sharma <divangsharma@microsoft.com> Co-authored-by: David Engel <davidengel@microsoft.com>
divang
added a commit
that referenced
this pull request
Jun 13, 2025
…th AAD auth (#2668) (#2684) * In case of federated authentication request, do not terminate the connection to resolve Fed auth connection resiliency issue * In place of serverSupportsDNSCaching, routingInfo value is a better choice to take decision on connection termination. If endpoint is routed then no need to terminate the current connection. * Added mock test for connectionReconveryCheck() method --------- Co-authored-by: Divang Sharma <divangsharma@microsoft.com> Co-authored-by: David Engel <davidengel@microsoft.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This incident concerns a connectivity issue involving the JDBC driver (version 10) using the latest main branch, specifically when authenticating via Azure Active Directory Interactive. During reconnection attempts, the driver encounters a warning: the Session Recovery feature extension acknowledgment is not sent by the server.
Root Cause
This issue involves a connectivity problem in the JDBC driver (version 10, latest main branch) when using Azure Active Directory (AAD) authentication. After the SQL session (SPID) is killed, the driver's session recovery mechanism fails, leading to reconnection issues. This problem does not occur with SQL Authentication, where tokens are reusable. However, with AAD, the token cannot be reused after disconnection, complicating the recovery process.
The root cause lies in how the driver handles routing information during reconnect attempts. When the initial connection is made, the server provides routingInfo indicating that the connection should be redirected (a two-hop routing scenario):
If routingInfo is present, it implies the driver must follow this redirection path to complete the session recovery. However, the current behavior mistakenly terminates the connection prematurely, without attempting the redirect. This causes the driver to repeatedly retry the same initial connection, which never receives the required SESSIONRECOVERY extension.
Resolution
To resolve this issue, the JDBC driver must recognize when routingInfo is present in the server's response. This indicates a redirection is necessary and that the driver should:
Upon connecting to the redirected server, the expected TDS_FEATURE_EXT_SESSIONRECOVERY extension is received, allowing the session recovery process to proceed correctly. Implementing this behavior ensures compatibility with AAD authentication and proper failover handling during reconnect scenarios involving redirected endpoints.
Steps:
Testing
The following code simulates the scenario described above: