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

[WIP] Update client-side cache of prepared statements unconditionally #2

Draft
wants to merge 2 commits into
base: 3.2.0-yb-x
Choose a base branch
from
Draft
Changes from all 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 @@ -2241,14 +2241,10 @@ public void ensurePoolsSizing() {
}

public PreparedStatement addPrepared(PreparedStatement stmt) {
PreparedStatement previous = preparedQueries.putIfAbsent(stmt.getPreparedId().id, stmt);
PreparedStatement previous = preparedQueries.put(stmt.getPreparedId().id, stmt);
if (previous != null) {
logger.warn("Re-preparing already prepared query is generally an anti-pattern and will likely affect performance. "
+ "Consider preparing the statement only once. Query='{}'", stmt.getQueryString());

// The one object in the cache will get GCed once it's not referenced by the client anymore since we use a weak reference.
// So we need to make sure that the instance we do return to the user is the one that is in the cache.
return previous;
}
return stmt;
}
Expand Down