Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-06-15 09:06:27 +0000
committerEike Stepper2010-06-15 09:06:27 +0000
commit23a973a6fc99a07edea6b74e8710df37f543e388 (patch)
treedd39e6f8a13c36f192ce3bec7f283e0e41f6241f /plugins
parentdf1d8ef4413f73d804d9599a898f82328fd542f4 (diff)
downloadcdo-23a973a6fc99a07edea6b74e8710df37f543e388.tar.gz
cdo-23a973a6fc99a07edea6b74e8710df37f543e388.tar.xz
cdo-23a973a6fc99a07edea6b74e8710df37f543e388.zip
[316867] Raw replication fails after recovering from non-graceful shutdown
https://bugs.eclipse.org/bugs/show_bug.cgi?id=316867
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java30
2 files changed, 13 insertions, 33 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 ded9774a24..a1ca6a7f1c 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
@@ -545,16 +545,19 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
else
{
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);
+ long[] result = mappingStrategy.repairAfterCrash(dbAdapter, connection);
setNextLocalObjectID(result[0]);
setLastObjectID(result[1]);
- setLastMetaID(DBUtil.selectMaximumLong(connection, CDODBSchema.PACKAGE_INFOS_META_UB));
+
+ long lastMetaID = DBUtil.selectMaximumLong(connection, CDODBSchema.PACKAGE_INFOS_META_UB);
+ setLastMetaID(lastMetaID);
int branchID = DBUtil.selectMaximumInt(connection, CDODBSchema.BRANCHES_ID);
setLastBranchID(branchID > 0 ? branchID : 0);
@@ -562,8 +565,13 @@ public class DBStore extends LongIDStore implements IDBStore, CDOAllRevisionsPro
int localBranchID = DBUtil.selectMinimumInt(connection, CDODBSchema.BRANCHES_ID);
setLastLocalBranchID(localBranchID < 0 ? localBranchID : 0);
- setLastCommitTime(result[2]);
- setLastNonLocalCommitTime(result[3]);
+ long lastCommitTime = DBUtil.selectMaximumLong(connection, CDODBSchema.COMMIT_INFOS_TIMESTAMP);
+ setLastCommitTime(lastCommitTime);
+
+ long lastNonLocalCommitTime = DBUtil.selectMaximumLong(connection, CDODBSchema.COMMIT_INFOS_TIMESTAMP,
+ CDOBranch.MAIN_BRANCH_ID + "<=" + CDODBSchema.COMMIT_INFOS_BRANCH);
+ setLastNonLocalCommitTime(lastNonLocalCommitTime);
+
OM.LOG.info(MessageFormat.format(Messages.getString("DBStore.10"), getLastObjectID(), getLastMetaID())); //$NON-NLS-1$
}
catch (SQLException e)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
index bb315e5e1c..360b4e9a91 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
@@ -11,7 +11,6 @@
*/
package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
@@ -81,9 +80,8 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
{
long minLocalID = getMinLocalID(connection);
long maxID = objectTypeCache.getMaxID(connection);
- long[] maxTimes = getMaxTimes(connection);
- long[] result = { minLocalID, maxID, maxTimes[0], maxTimes[1] };
+ long[] result = { minLocalID, maxID };
return result;
}
@@ -309,30 +307,4 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
return min;
}
-
- private long[] getMaxTimes(Connection connection)
- {
- long max = CDORevision.UNSPECIFIED_DATE;
- long maxNonLocal = CDORevision.UNSPECIFIED_DATE;
- final String where = CDODBSchema.ATTRIBUTES_BRANCH + ">=" + CDOBranch.MAIN_BRANCH_ID;
-
- for (IClassMapping classMapping : getClassMappings().values())
- {
- IDBTable table = classMapping.getDBTables().get(0);
- IDBField field = table.getField(CDODBSchema.ATTRIBUTES_CREATED);
- long timeStamp = DBUtil.selectMaximumLong(connection, field);
- if (timeStamp > max)
- {
- max = timeStamp;
- }
-
- timeStamp = DBUtil.selectMaximumLong(connection, field, where);
- if (timeStamp > maxNonLocal)
- {
- maxNonLocal = timeStamp;
- }
- }
-
- return new long[] { max, maxNonLocal };
- }
}

Back to the top