Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-03-06 05:41:05 -0500
committerEike Stepper2013-03-07 08:44:45 -0500
commit8ca05d4d1e64f58208b1390ad03a2176ade9121a (patch)
tree5e9e48cff0e9b911105427ddbc68a11f3c1c26d1
parent4cdc6668f105dc3c1f3be2a679968b9e8c1720b2 (diff)
downloadcdo-8ca05d4d1e64f58208b1390ad03a2176ade9121a.tar.gz
cdo-8ca05d4d1e64f58208b1390ad03a2176ade9121a.tar.xz
cdo-8ca05d4d1e64f58208b1390ad03a2176ade9121a.zip
[401763] Make CDO Server more robust against data dictionary changes
https://bugs.eclipse.org/bugs/show_bug.cgi?id=401763
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IPreparedStatementCache.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java35
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java61
4 files changed, 7 insertions, 99 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
index c95999e648..b779c3f49f 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
@@ -46,6 +46,11 @@ public interface IDBStore extends IStore, IDBConnectionProvider, CanHandleClient
*/
public IIDHandler getIDHandler();
+ /**
+ * @since 4.2
+ */
+ // public IDBDatabase getDatabase();
+
public IDBAdapter getDBAdapter();
public IDBSchema getDBSchema();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IPreparedStatementCache.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IPreparedStatementCache.java
index 0c36a68023..5cd4634393 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IPreparedStatementCache.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IPreparedStatementCache.java
@@ -31,11 +31,6 @@ public interface IPreparedStatementCache
public void releasePreparedStatement(PreparedStatement ps);
/**
- * @since 4.2
- */
- public void invalidate();
-
- /**
* An enum for the degree of probability to which a prepared statement is reused later on. This is used for managing
* the cache of prepared statements so that statements which are more likely reused are kept in the cache longer. Rule
* of thumb:
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index 3a02869bde..626d4d7cb9 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -67,8 +67,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Timer;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* @author Eike Stepper
@@ -117,26 +115,14 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
private IMappingStrategy mappingStrategy;
+ // private IDBDatabase database;
+
private IDBSchema dbSchema;
private IDBAdapter dbAdapter;
private IDBConnectionProvider dbConnectionProvider;
- /**
- * A global database-level lock to secure data read/write operations against data dictionary changes (DML vs. DDL).
- *
- * @see DBStoreAccessor#doWrite
- * @see DBStoreAccessor#doCommit
- * @see DBStoreAccessor#doRollback
- */
- private ReentrantReadWriteLock dbSchemaLock;
-
- /**
- * A transient version number that accessors rely upon to determine whether they need to invalidate their prepared statement caches.
- */
- private int dbSchemaModCount;
-
@ExcludeFromDump
private transient ProgressDistributor accessorWriteDistributor = new ProgressDistributor.Geometric()
{
@@ -277,21 +263,6 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
return dbSchema;
}
- public ReadWriteLock getDBSchemaLock()
- {
- return dbSchemaLock;
- }
-
- public int getDBSchemaModCount()
- {
- return dbSchemaModCount;
- }
-
- public int incDBSchemaModCount()
- {
- return ++dbSchemaModCount;
- }
-
public void visitAllTables(Connection connection, IDBStore.TableVisitor visitor)
{
for (String name : DBUtil.getAllTableNames(connection, getRepository().getName()))
@@ -654,8 +625,6 @@ public class DBStore extends Store implements IDBStore, CDOAllRevisionsProvider
}
dbSchema = createSchema();
- dbSchemaLock = new ReentrantReadWriteLock();
- dbSchemaModCount = 1;
LifecycleUtil.activate(idHandler);
LifecycleUtil.activate(metaDataManager);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index d36f911576..d679abdec8 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -106,7 +106,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimerTask;
-import java.util.concurrent.locks.Lock;
/**
* @author Eike Stepper
@@ -125,10 +124,6 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
private CDOID maxID = CDOID.NULL;
- private Lock dbSchemaLock;
-
- private int dbSchemaModCount;
-
public DBStoreAccessor(DBStore store, ISession session) throws DBException
{
super(store, session);
@@ -691,13 +686,6 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
}
@Override
- protected void doWrite(InternalCommitContext context, OMMonitor monitor)
- {
- lockSchema(context);
- super.doWrite(context, monitor);
- }
-
- @Override
protected final void doCommit(OMMonitor monitor)
{
if (TRACER.isEnabled())
@@ -736,7 +724,6 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
}
finally
{
- unlockSchema();
monitor.done();
}
}
@@ -762,46 +749,6 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
{
throw new DBException(ex);
}
- finally
- {
- unlockSchema();
- }
- }
-
- private void lockSchema(InternalCommitContext context)
- {
- DBStore store = getStore();
-
- InternalCDOPackageUnit[] newPackageUnits = context.getNewPackageUnits();
- if (!ObjectUtil.isEmpty(newPackageUnits))
- {
- // This transaction will possibly execute DDL, so we need an exclusive lock
- dbSchemaLock = store.getDBSchemaLock().writeLock();
- }
- else
- {
- // No DDL, so we are ok with a simple concurrent lock
- dbSchemaLock = store.getDBSchemaLock().readLock();
- }
-
- dbSchemaLock.lock();
-
- // Check if our prepared statement cache is still usable
- int storeModCount = store.getDBSchemaModCount();
- if (dbSchemaModCount != storeModCount)
- {
- statementCache.invalidate();
- dbSchemaModCount = storeModCount;
- }
- }
-
- private void unlockSchema()
- {
- if (dbSchemaLock != null)
- {
- dbSchemaLock.unlock();
- dbSchemaLock = null;
- }
}
@Override
@@ -828,8 +775,6 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
statementCache = CDODBUtil.createStatementCache();
statementCache.setConnection(connection);
LifecycleUtil.activate(statementCache);
-
- dbSchemaModCount = store.getDBSchemaModCount();
}
@Override
@@ -885,12 +830,6 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
}
finally
{
- // most likely, we have modified the database definition structure. So, we
- // reflect this by incrementing the version which forces all other DBStoreAccessors
- // to invalidate their statementCache, and we invalidate ours, too.
- statementCache.invalidate();
- dbSchemaModCount = getStore().incDBSchemaModCount();
-
monitor.done();
}
}

Back to the top