Skip to content

issue#2537 - Fix for SQLServerConnection infinite loop#2547

Merged
machavan merged 3 commits intomainfrom
dev/machavan/issue#2537
Nov 27, 2024
Merged

issue#2537 - Fix for SQLServerConnection infinite loop#2547
machavan merged 3 commits intomainfrom
dev/machavan/issue#2537

Conversation

@machavan
Copy link
Copy Markdown
Contributor

@machavan machavan commented Nov 25, 2024

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:

  • All unit tests passed
  • The existing test RequestBoundaryMethodsTest specifically validates this code path.

@machavan
Copy link
Copy Markdown
Contributor Author

Testing:

  • All unit tests passed
  • The existing test RequestBoundaryMethodsTest specifically validates this code path.

Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 50.96%. Comparing base (fc0cfab) to head (815069a).
Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

@lilgreenbird lilgreenbird linked an issue Nov 25, 2024 that may be closed by this pull request
Comment thread src/main/java/com/microsoft/sqlserver/jdbc/SQLServerConnection.java Outdated
@Jeffery-Wasty
Copy link
Copy Markdown
Contributor

@machavan You need to agree to the CLA in the following format:

@microsoft-github-policy-service agree [company="{your company}"]

Before we can merge the PR.

@machavan
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree [company="{Microsoft}"]

@machavan
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Microsoft"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed/Merged PRs

Development

Successfully merging this pull request may close these issues.

SQLServerConnection infinite loop

5 participants