summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2010-05-08 08:45:25 (EDT)
committerStefan Winkler2010-05-08 08:45:25 (EDT)
commitc09ee822cd39f5d592b40fd1cb936b855a328bc9 (patch)
tree8f5675caff467b5447f84caea33bbc0c1c3b6f98
parentd8305ae619d23529626bcbdd20b60bd5f4b148a1 (diff)
downloadcdo-c09ee822cd39f5d592b40fd1cb936b855a328bc9.zip
cdo-c09ee822cd39f5d592b40fd1cb936b855a328bc9.tar.gz
cdo-c09ee822cd39f5d592b40fd1cb936b855a328bc9.tar.bz2
[306000] [DB] Derby: Lock could not be obtained exception while initializing property table
https://bugs.eclipse.org/bugs/show_bug.cgi?id=306000
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/messages/messages.properties1
2 files changed, 40 insertions, 23 deletions
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 4803688..0fe72fc 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
@@ -436,18 +436,10 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
Connection connection = getConnection();
LifecycleUtil.activate(mappingStrategy);
+ Set<IDBTable> createdTables = null;
try
{
- Set<IDBTable> createdTables = CDODBSchema.INSTANCE.create(dbAdapter, connection);
- if (createdTables.contains(CDODBSchema.PROPERTIES))
- {
- firstStart(connection);
- }
- else
- {
- reStart(connection);
- }
-
+ createdTables = CDODBSchema.INSTANCE.create(dbAdapter, connection);
connection.commit();
}
finally
@@ -455,6 +447,15 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
DBUtil.close(connection);
}
+ if (createdTables.contains(CDODBSchema.PROPERTIES))
+ {
+ firstStart();
+ }
+ else
+ {
+ reStart();
+ }
+
externalReferenceManager = createExternalReferenceManager();
externalReferenceManager.setStore(this);
LifecycleUtil.activate(externalReferenceManager);
@@ -488,7 +489,7 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
super.doDeactivate();
}
- protected void firstStart(Connection connection)
+ protected void firstStart()
{
creationTime = getRepository().getTimeStamp();
firstTime = true;
@@ -500,7 +501,7 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
OM.LOG.info(MessageFormat.format(Messages.getString("DBStore.8"), creationTime)); //$NON-NLS-1$
}
- protected void reStart(Connection connection)
+ protected void reStart()
{
Set<String> names = new HashSet<String>();
names.add(PROP_REPOSITORY_CREATED);
@@ -529,21 +530,36 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
}
else
{
- OM.LOG.info(Messages.getString("DBStore.9")); //$NON-NLS-1$
- long[] result = mappingStrategy.repairAfterCrash(dbAdapter, connection);
+ Connection connection = getConnection();
+ try
+ {
+ connection.setAutoCommit(false);
+ connection.setReadOnly(true);
+ OM.LOG.info(Messages.getString("DBStore.9")); //$NON-NLS-1$
+ long[] result = mappingStrategy.repairAfterCrash(dbAdapter, connection);
- setNextLocalObjectID(result[0]);
- setLastObjectID(result[1]);
- setLastMetaID(DBUtil.selectMaximumLong(connection, CDODBSchema.PACKAGE_INFOS_META_UB));
+ setNextLocalObjectID(result[0]);
+ setLastObjectID(result[1]);
+ setLastMetaID(DBUtil.selectMaximumLong(connection, CDODBSchema.PACKAGE_INFOS_META_UB));
- int branchID = DBUtil.selectMaximumInt(connection, CDODBSchema.BRANCHES_ID);
- setLastBranchID(branchID > 0 ? branchID : 0);
+ int branchID = DBUtil.selectMaximumInt(connection, CDODBSchema.BRANCHES_ID);
+ setLastBranchID(branchID > 0 ? branchID : 0);
- int localBranchID = DBUtil.selectMinimumInt(connection, CDODBSchema.BRANCHES_ID);
- setLastLocalBranchID(localBranchID < 0 ? localBranchID : 0);
+ int localBranchID = DBUtil.selectMinimumInt(connection, CDODBSchema.BRANCHES_ID);
+ setLastLocalBranchID(localBranchID < 0 ? localBranchID : 0);
- setLastCommitTime(result[2]);
- OM.LOG.info(MessageFormat.format(Messages.getString("DBStore.10"), getLastObjectID(), getLastMetaID())); //$NON-NLS-1$
+ setLastCommitTime(result[2]);
+ OM.LOG.info(MessageFormat.format(Messages.getString("DBStore.10"), getLastObjectID(), getLastMetaID())); //$NON-NLS-1$
+ }
+ catch (SQLException e)
+ {
+ OM.LOG.error(Messages.getString("DBStore.12"), e); //$NON-NLS-1$
+ throw new DBException(e);
+ }
+ finally
+ {
+ DBUtil.close(connection);
+ }
}
removePropertyValues(Collections.singleton(PROP_GRACEFULLY_SHUT_DOWN));
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/messages/messages.properties b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/messages/messages.properties
index 3b2f04f..76fd83d 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/messages/messages.properties
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/messages/messages.properties
@@ -16,3 +16,4 @@ DBStore.7=AuditSupport of MappingStrategy and Store does not match. Please check
DBStore.8=First start: {0,date} {0,time}
DBStore.9=Detected crash
DBStore.11=BranchingSupport of MappingStrategy and Store do not match. Please check configuration.
+DBStore.12=Repairing after crash failed.