Skip to content
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

Fix prepared statement metadata cache issue #543

Merged
merged 14 commits into from
Nov 17, 2017
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@

// Note all the public functions in this class also need to be defined in SQLServerConnectionPoolProxy.
public class SQLServerConnection implements ISQLServerConnection {
boolean contextIsAlreadyChanged = false;
boolean contextChanged = false;

long timerExpire;
boolean attemptRefreshTokenLocked = false;

Expand Down Expand Up @@ -3079,6 +3082,8 @@ final void poolCloseEventNotify() throws SQLServerException {
checkClosed();
if (catalog != null) {
connectionCommand("use " + Util.escapeSQLId(catalog), "setCatalog");
contextIsAlreadyChanged = true;
contextChanged = true;
sCatalog = catalog;
}
loggerExternal.exiting(getClassNameLogging(), "setCatalog");
Expand Down Expand Up @@ -5760,6 +5765,12 @@ final void evictCachedPreparedStatementHandle(PreparedStatementHandle handle) {
preparedStatementHandleCache.remove(handle.getKey());
}

final void clearCachedPreparedStatementHandle() {
if (null != preparedStatementHandleCache) {
preparedStatementHandleCache.clear();
}
}

// Handle closing handles when removed from cache.
final class PreparedStatementCacheEvictionListener implements EvictionListener<Sha1HashKey, PreparedStatementHandle> {
public void onEviction(Sha1HashKey key, PreparedStatementHandle handle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ public void run() {
if (bIsOpen && (null != wrappedConnection)) {
if (wrappedConnection.getConnectionLogger().isLoggable(Level.FINER))
wrappedConnection.getConnectionLogger().finer(toString() + " Connection proxy closed ");

// clear cached prepared statement handle on this connection
wrappedConnection.clearCachedPreparedStatementHandle();
wrappedConnection.poolCloseEventNotify();
wrappedConnection = null;
}
Expand Down
Loading