-
Notifications
You must be signed in to change notification settings - Fork 428
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
issue#2537 - Fix for SQLServerConnection infinite loop #2547
Conversation
Testing:
|
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2547 +/- ##
=========================================
Coverage 50.96% 50.96%
- Complexity 3912 3915 +3
=========================================
Files 147 147
Lines 33460 33462 +2
Branches 5608 5607 -1
=========================================
+ Hits 17052 17055 +3
- Misses 13999 14000 +1
+ Partials 2409 2407 -2 ☔ View full report in Codecov by Sentry. |
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java
Outdated
Show resolved
Hide resolved
@machavan You need to agree to the CLA in the following format:
Before we can merge the PR. |
@microsoft-github-policy-service agree [company="{Microsoft}"] |
@microsoft-github-policy-service agree company="Microsoft" |
Description:
Based on issue analysis
"Could be looping infinitely because bIsClosed could be true. bIsClosed could have been set to true earlier somewhere."
we are improving the infinite loop to close all statements present in openStatements , remove them from it explicitly and terminate.
Also, it looks like this could be happening as connections/statements are being used across threads based on the issue description.
bIsClosed and openStatements are not volatile, and as a result a thread creating statements while under a request ( started using beginRequest) may add them in openStatements list, with some other thread closing them but not removing from openStatements just due to that thread having read a stale value(null) of openStatements( and other combinations of issues of this sort). Hence, we are making bIsClosed and openStatements volatile.
Testing: