Skip to content

Invalidate existing enclave session during connection (re)connect #2638

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

machavan
Copy link
Contributor

Description:

For AE with secure enclave, the driver connections receives an error 33195 - Internal enclave error. Enclave was provided with an invalid session handle. For more information, contact Customer Support Services, post failovers ( in case of Always On setup).

This could be happening because of driver using existing enclave session from the enclaveCache in the driver.

This fix invalidates the existing enclave session as part of the connect method.

@github-project-automation github-project-automation bot moved this to In progress in MSSQL JDBC Mar 26, 2025
@machavan machavan changed the title Invalidate existing enclave session in during (re)connect Invalidate existing enclave session during connection (re)connect Mar 26, 2025
Copy link

codecov bot commented Mar 26, 2025

Codecov Report

Attention: Patch coverage is 16.66667% with 10 lines in your changes missing coverage. Please review.

Project coverage is 51.51%. Comparing base (9caba4d) to head (b83e896).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../microsoft/sqlserver/jdbc/SQLServerConnection.java 25.00% 5 Missing and 1 partial ⚠️
...oft/sqlserver/jdbc/SQLServerPreparedStatement.java 0.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2638      +/-   ##
============================================
- Coverage     51.52%   51.51%   -0.01%     
+ Complexity     3990     3988       -2     
============================================
  Files           147      147              
  Lines         33706    33720      +14     
  Branches       5631     5636       +5     
============================================
+ Hits          17366    17371       +5     
- Misses        13886    13894       +8     
- Partials       2454     2455       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@lilgreenbird lilgreenbird left a comment

Choose a reason for hiding this comment

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

need to add test

Comment on lines +2197 to +2202
if (enclaveProvider != null) {
if (connectionlogger.isLoggable(Level.FINE)) {
connectionlogger.fine("Invalidating existing enclave session for enclave provider : " + enclaveProvider);
}
enclaveProvider.invalidateEnclaveSession();
}
Copy link
Collaborator

@David-Engel David-Engel Apr 28, 2025

Choose a reason for hiding this comment

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

Can this be changed to just call invalidateEnclaveSessionCache() now?

Copy link
Collaborator

@David-Engel David-Engel left a comment

Choose a reason for hiding this comment

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

No blockers. One small white space nit and if we can de-dup the code block, that'd be great. Approved with or without the changes.

@@ -87,7 +89,7 @@ public final class SQLServerException extends java.sql.SQLException {
static final int DATA_CLASSIFICATION_NOT_EXPECTED = 11;
static final int DATA_CLASSIFICATION_INVALID_LABEL_INDEX = 12;
static final int DATA_CLASSIFICATION_INVALID_INFORMATION_TYPE_INDEX = 13;

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Stray empty space

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

3 participants