Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2012-01-30 05:55:12 -0500
committerStefan Winkler2012-01-30 05:55:12 -0500
commit657c570d2d94980416e6d7d248c47bcaabc1c550 (patch)
tree8320740ee85694b4c32bd540232856149de5b77d
parente8b7929a0576c30747672a198eccc8a36d78357a (diff)
downloadcdo-657c570d2d94980416e6d7d248c47bcaabc1c550.tar.gz
cdo-657c570d2d94980416e6d7d248c47bcaabc1c550.tar.xz
cdo-657c570d2d94980416e6d7d248c47bcaabc1c550.zip
[370105] [DB] CommitException: SELECT-statement already in cache
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370105 Added tracing to statement cache
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SmartPreparedStatementCache.java17
1 files changed, 17 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SmartPreparedStatementCache.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SmartPreparedStatementCache.java
index 6018a33077..e836077973 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SmartPreparedStatementCache.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SmartPreparedStatementCache.java
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.util.ImplementationError;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -26,6 +27,8 @@ import java.util.HashMap;
*/
public class SmartPreparedStatementCache extends AbstractPreparedStatementCache
{
+ private static ContextTracer TRACER = new ContextTracer(OM.DEBUG, SmartPreparedStatementCache.class);
+
private Cache cache;
private HashMap<PreparedStatement, CachedPreparedStatement> checkedOut = new HashMap<PreparedStatement, CachedPreparedStatement>();
@@ -38,9 +41,19 @@ public class SmartPreparedStatementCache extends AbstractPreparedStatementCache
public PreparedStatement getPreparedStatement(String sql, ReuseProbability reuseProbability)
{
CachedPreparedStatement cachedStatement = cache.remove(sql);
+
+ if (TRACER.isEnabled() && cachedStatement != null)
+ {
+ TRACER.format("Cache hit: {0}", cachedStatement.getSQL());
+ }
+
if (cachedStatement == null)
{
cachedStatement = createCachedPreparedStatement(sql, reuseProbability);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Cache miss - created statement: {0}", cachedStatement.getSQL());
+ }
}
PreparedStatement result = cachedStatement.getPreparedStatement();
@@ -58,6 +71,10 @@ public class SmartPreparedStatementCache extends AbstractPreparedStatementCache
if (ps != null) // Bug 276926: Silently accept ps == null and do nothing.
{
CachedPreparedStatement cachedStatement = checkedOut.remove(ps);
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Releasing statement to cache: {0}", cachedStatement.getSQL());
+ }
cache.put(cachedStatement);
}
}

Back to the top