Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2012-01-30 05:56:26 -0500
committerStefan Winkler2012-01-30 05:56:26 -0500
commit516ad28272f67d3d50d10504a331946dac0c375c (patch)
tree9a6c5fc54c8cb07086d3e264cad64a20be655c71
parent657c570d2d94980416e6d7d248c47bcaabc1c550 (diff)
downloadcdo-516ad28272f67d3d50d10504a331946dac0c375c.tar.gz
cdo-516ad28272f67d3d50d10504a331946dac0c375c.tar.xz
cdo-516ad28272f67d3d50d10504a331946dac0c375c.zip
[370105] [DB] CommitException: SELECT-statement already in cache
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370105 Fix: release statements BEFORE calling reading operations on base revision
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java39
2 files changed, 40 insertions, 32 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
index bb6bb589de..128ac25cf3 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
@@ -53,6 +53,7 @@ import org.eclipse.net4j.db.ddl.IDBIndex.Type;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.ImplementationError;
import org.eclipse.net4j.util.collection.MoveableList;
+import org.eclipse.net4j.util.collection.Pair;
import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.ecore.EClass;
@@ -63,6 +64,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
@@ -316,7 +318,8 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
PreparedStatement stmt = null;
ResultSet resultSet = null;
- IStoreChunkReader baseReader = null;
+ // list of chunks to be read from base revision
+ ArrayList<Pair<Integer, Integer>> toReadFromBase = null;
try
{
String sql = sqlSelectChunksPrefix + sqlOrderByIndex;
@@ -336,12 +339,12 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
int index = resultSet.getInt(1);
if (index > currentIndex)
{
- if (baseReader == null)
+ if (toReadFromBase == null)
{
- baseReader = createBaseChunkReader(accessor, id, branchID);
+ toReadFromBase = new ArrayList<Pair<Integer, Integer>>();
}
+ toReadFromBase.add(new Pair<Integer, Integer>(currentIndex, index));
- baseReader.addRangedChunk(currentIndex, index);
if (TRACER.isEnabled())
{
TRACER.format("Scheduling range {0}-{1} to be read from base revision", currentIndex, index); //$NON-NLS-1$
@@ -363,17 +366,11 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
if (valuesToRead > 0)
{
- if (baseReader == null)
- {
- baseReader = createBaseChunkReader(accessor, id, branchID);
- }
-
- baseReader.addRangedChunk(currentIndex, currentIndex + valuesToRead);
- if (TRACER.isEnabled())
+ if (toReadFromBase == null)
{
- TRACER.format(
- "Scheduling range {0}-{1} to be read from base revision", currentIndex, currentIndex + valuesToRead); //$NON-NLS-1$
+ toReadFromBase = new ArrayList<Pair<Integer, Integer>>();
}
+ toReadFromBase.add(new Pair<Integer, Integer>(currentIndex, currentIndex + valuesToRead));
}
}
catch (SQLException ex)
@@ -386,14 +383,22 @@ public class BranchingListTableMappingWithRanges extends BasicAbstractListTableM
statementCache.releasePreparedStatement(stmt);
}
- if (baseReader != null)
+ // read missing values from base revision ...
+ if (toReadFromBase != null)
{
+ IStoreChunkReader baseReader = createBaseChunkReader(accessor, id, branchID);
+
if (TRACER.isEnabled())
{
TRACER.format("Reading base revision chunks for feature {0}.{1} of {2} from base revision {3}", //$NON-NLS-1$
getContainingClass().getName(), getFeature().getName(), revision, baseReader.getRevision());
}
+ for (Pair<Integer, Integer> range : toReadFromBase)
+ {
+ baseReader.addRangedChunk(range.getElement1(), range.getElement2());
+ }
+
List<Chunk> baseChunks = baseReader.executeRead();
for (Chunk chunk : baseChunks)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
index 2ac02db01c..9c57532e27 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
@@ -416,6 +416,8 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
long timeStamp = revision.getTimeStamp();
int branchID = revision.getBranch().getID();
+ boolean success = false;
+
try
{
if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE)
@@ -434,15 +436,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
}
// Read singleval-attribute table always (even without modeled attributes!)
- boolean success = readValuesFromStatement(stmt, revision, accessor);
-
- // Read multival tables only if revision exists
- if (success && revision.getVersion() >= CDOBranchVersion.FIRST_VERSION)
- {
- readLists(accessor, revision, listChunk);
- }
-
- return success;
+ success = readValuesFromStatement(stmt, revision, accessor);
}
catch (SQLException ex)
{
@@ -452,6 +446,14 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
{
statementCache.releasePreparedStatement(stmt);
}
+
+ // Read multival tables only if revision exists
+ if (success && revision.getVersion() >= CDOBranchVersion.FIRST_VERSION)
+ {
+ readLists(accessor, revision, listChunk);
+ }
+
+ return success;
}
public boolean readRevisionByVersion(IDBStoreAccessor accessor, InternalCDORevision revision, int listChunk)
@@ -460,6 +462,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
IPreparedStatementCache statementCache = accessor.getStatementCache();
PreparedStatement stmt = null;
+ boolean success = false;
try
{
stmt = statementCache.getPreparedStatement(sqlSelectAttributesByVersion, ReuseProbability.HIGH);
@@ -468,15 +471,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
stmt.setInt(3, revision.getVersion());
// Read singleval-attribute table always (even without modeled attributes!)
- boolean success = readValuesFromStatement(stmt, revision, accessor);
-
- // Read multival tables only if revision exists
- if (success)
- {
- readLists(accessor, revision, listChunk);
- }
-
- return success;
+ success = readValuesFromStatement(stmt, revision, accessor);
}
catch (SQLException ex)
{
@@ -486,6 +481,14 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
{
statementCache.releasePreparedStatement(stmt);
}
+
+ // Read multival tables only if revision exists
+ if (success)
+ {
+ readLists(accessor, revision, listChunk);
+ }
+
+ return success;
}
public PreparedStatement createResourceQueryStatement(IDBStoreAccessor accessor, CDOID folderId, String name,

Back to the top