-
Notifications
You must be signed in to change notification settings - Fork 426
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
Added cleanup task to start of every execute. #2272
Conversation
Îs using force=true the right thing here? doesn’t that add roundtrips? (Besides that the change seems to address the issue but I wonder if the logic can’t be in the place where the handles are orphaned - not sure where). |
For sure this can be improved. I have only opened this PR so the user can see our proposed changes and try testing them out, and see if that resolves the issue. For an actual fix, we will look into a cleaner and more performance-friendly solution. |
ah yes, I understand, makes sense. it will check if it fixes the handles accumulated in my reproducer test, but of course not sure if that is the exact problem of OP |
No we're not, but from the information we have, this is the best guess. |
For the production fix, I'd set force to false. (Assuming this is the fix.) We don't need to be super aggressive on the cleanup. It's just that if an application is doing millions of executions of a PreparedStatement and some of them occasionally result in an invalidated prepared statement handle, we should clean up periodically to avoid continuously increasing memory usage. Current cleanup only happens on close of the PreparedStatement and connection close. |
src/test/java/com/microsoft/sqlserver/jdbc/unit/statement/PreparedStatementTest.java
Outdated
Show resolved
Hide resolved
src/main/java/com/microsoft/sqlserver/jdbc/SQLServerPreparedStatement.java
Show resolved
Hide resolved
4b4f0dc
to
9bb0f3e
Compare
d9f1364
to
9568e96
Compare
Under certain conditions, prepared statement cache can end up being filled quicker than expected, while being cleaned less often than expected. This adds additional cache clean triggers making the cleaning much more frequent.