Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-03-21 08:02:35 +0000
committerEike Stepper2020-03-21 08:02:35 +0000
commit5bb5274f9d41dd0f6004c089050634b6cff69642 (patch)
treeb25ec96f2f6976780a59b47d29270f83228db3b3
parent2c9ec6da104ad258d2dea71fc0286759122ba2ea (diff)
downloadcdo-5bb5274f9d41dd0f6004c089050634b6cff69642.tar.gz
cdo-5bb5274f9d41dd0f6004c089050634b6cff69642.tar.xz
cdo-5bb5274f9d41dd0f6004c089050634b6cff69642.zip
[560957] Deadlock when using CDOMergingConflictResolver
https://bugs.eclipse.org/bugs/show_bug.cgi?id=560957
-rw-r--r--features/org.eclipse.emf.cdo.server-feature/feature.xml2
-rw-r--r--features/org.eclipse.emf.cdo.server-feature/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_560957_Test.java102
-rw-r--r--plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF52
-rw-r--r--plugins/org.eclipse.emf.cdo/pom.xml2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java161
6 files changed, 167 insertions, 154 deletions
diff --git a/features/org.eclipse.emf.cdo.server-feature/feature.xml b/features/org.eclipse.emf.cdo.server-feature/feature.xml
index 51355cb5e1..c24df591c5 100644
--- a/features/org.eclipse.emf.cdo.server-feature/feature.xml
+++ b/features/org.eclipse.emf.cdo.server-feature/feature.xml
@@ -12,7 +12,7 @@
<feature
id="org.eclipse.emf.cdo.server"
label="%featureName"
- version="4.9.0.qualifier"
+ version="4.9.1.qualifier"
provider-name="%providerName"
image="eclipse_update_120.jpg"
license-feature="org.eclipse.emf.cdo.license"
diff --git a/features/org.eclipse.emf.cdo.server-feature/pom.xml b/features/org.eclipse.emf.cdo.server-feature/pom.xml
index c40744e05c..c92ca6e6e6 100644
--- a/features/org.eclipse.emf.cdo.server-feature/pom.xml
+++ b/features/org.eclipse.emf.cdo.server-feature/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo.features</groupId>
<artifactId>org.eclipse.emf.cdo.server</artifactId>
- <version>4.9.0-SNAPSHOT</version>
+ <version>4.9.1-SNAPSHOT</version>
<packaging>eclipse-feature</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_560957_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_560957_Test.java
new file mode 100644
index 0000000000..9bec13af9e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_560957_Test.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2020 Eike Stepper (Loehne, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.net4j.util.WrappedException;
+
+import java.util.concurrent.CountDownLatch;
+
+/**
+ * Bug 560957 - Deadlock when using CDOMergingConflictResolver.
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_560957_Test extends AbstractCDOTest
+{
+ public void testDeadlockOnViewGetBranch() throws Exception
+ {
+ CDOSession session = openSession();
+
+ CDOTransaction transaction1 = session.openTransaction();
+ transaction1.createResource(getResourcePath("resource" + transaction1.getViewID()));
+ transaction1.commit();
+
+ CDOTransaction transaction2 = session.openTransaction();
+ transaction2.createResource(getResourcePath("resource" + transaction2.getViewID()));
+ transaction2.commit();
+
+ CountDownLatch allThreadsCalledCommit = new CountDownLatch(2);
+ CountDownLatch allThreadsAccessedOtherBranchPoint = new CountDownLatch(2);
+
+ class Committer extends Thread
+ {
+ private final CDOTransaction transaction;
+
+ private final CDOTransaction otherTransaction;
+
+ public Committer(CDOTransaction transaction, CDOTransaction otherTransaction)
+ {
+ super("COMMITTER-" + transaction.getViewID());
+ setDaemon(true);
+
+ this.transaction = transaction;
+ this.otherTransaction = otherTransaction;
+
+ session.addListener(event -> {
+ if (event instanceof CDOSessionInvalidationEvent)
+ {
+ sessionInvalidated();
+ }
+ });
+ }
+
+ @Override
+ public void run()
+ {
+ // Make transaction dirty.
+ CDOResource resource = transaction.getResource(getResourcePath("resource" + transaction.getViewID()));
+ resource.getContents().add(getModel1Factory().createCompany());
+
+ try
+ {
+ transaction.commit();
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+
+ allThreadsAccessedOtherBranchPoint.countDown();
+ }
+
+ private void sessionInvalidated()
+ {
+ allThreadsCalledCommit.countDown();
+ await(allThreadsCalledCommit);
+
+ // Call the methods on the other transaction that can lead to deadlock.
+ otherTransaction.getBranch();
+ otherTransaction.getTimeStamp();
+ otherTransaction.isHistorical();
+ }
+ }
+
+ new Committer(transaction1, transaction2).start();
+ new Committer(transaction2, transaction1).start();
+ await(allThreadsAccessedOtherBranchPoint);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
index 47fd0aef29..d51e7ebed0 100644
--- a/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.emf.cdo; singleton:=true
-Bundle-Version: 4.9.0.qualifier
+Bundle-Version: 4.9.1.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -10,28 +10,28 @@ Bundle-Activator: org.eclipse.emf.internal.cdo.bundle.Activator$Implementation
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)";resolution:=optional,
org.eclipse.emf.cdo.common;bundle-version="[4.0.0,5.0.0)";visibility:=reexport
-Export-Package: org.eclipse.emf.cdo;version="4.9.0",
- org.eclipse.emf.cdo.eresource;version="4.9.0",
- org.eclipse.emf.cdo.eresource.impl;version="4.9.0",
- org.eclipse.emf.cdo.eresource.util;version="4.9.0",
- org.eclipse.emf.cdo.eresource.validation;version="4.9.0",
- org.eclipse.emf.cdo.etypes;version="4.9.0",
- org.eclipse.emf.cdo.etypes.impl;version="4.9.0",
- org.eclipse.emf.cdo.etypes.util;version="4.9.0",
- org.eclipse.emf.cdo.session;version="4.9.0",
- org.eclipse.emf.cdo.session.remote;version="4.9.0",
- org.eclipse.emf.cdo.transaction;version="4.9.0",
- org.eclipse.emf.cdo.util;version="4.9.0",
- org.eclipse.emf.cdo.view;version="4.9.0",
- org.eclipse.emf.internal.cdo;version="4.9.0",
- org.eclipse.emf.internal.cdo.analyzer;version="4.9.0";
+Export-Package: org.eclipse.emf.cdo;version="4.9.1",
+ org.eclipse.emf.cdo.eresource;version="4.9.1",
+ org.eclipse.emf.cdo.eresource.impl;version="4.9.1",
+ org.eclipse.emf.cdo.eresource.util;version="4.9.1",
+ org.eclipse.emf.cdo.eresource.validation;version="4.9.1",
+ org.eclipse.emf.cdo.etypes;version="4.9.1",
+ org.eclipse.emf.cdo.etypes.impl;version="4.9.1",
+ org.eclipse.emf.cdo.etypes.util;version="4.9.1",
+ org.eclipse.emf.cdo.session;version="4.9.1",
+ org.eclipse.emf.cdo.session.remote;version="4.9.1",
+ org.eclipse.emf.cdo.transaction;version="4.9.1",
+ org.eclipse.emf.cdo.util;version="4.9.1",
+ org.eclipse.emf.cdo.view;version="4.9.1",
+ org.eclipse.emf.internal.cdo;version="4.9.1",
+ org.eclipse.emf.internal.cdo.analyzer;version="4.9.1";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.ui",
- org.eclipse.emf.internal.cdo.bundle;version="4.9.0";x-friends:="org.eclipse.emf.cdo.ui",
- org.eclipse.emf.internal.cdo.messages;version="4.9.0";x-internal:=true,
- org.eclipse.emf.internal.cdo.object;version="4.9.0";
+ org.eclipse.emf.internal.cdo.bundle;version="4.9.1";x-friends:="org.eclipse.emf.cdo.ui",
+ org.eclipse.emf.internal.cdo.messages;version="4.9.1";x-internal:=true,
+ org.eclipse.emf.internal.cdo.object;version="4.9.1";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
@@ -40,12 +40,12 @@ Export-Package: org.eclipse.emf.cdo;version="4.9.0",
org.eclipse.emf.cdo.explorer,
org.eclipse.emf.cdo.explorer.ui,
org.eclipse.emf.cdo.edit",
- org.eclipse.emf.internal.cdo.query;version="4.9.0";
+ org.eclipse.emf.internal.cdo.query;version="4.9.1";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.ui",
- org.eclipse.emf.internal.cdo.session;version="4.9.0";
+ org.eclipse.emf.internal.cdo.session;version="4.9.1";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
@@ -55,23 +55,23 @@ Export-Package: org.eclipse.emf.cdo;version="4.9.0",
org.eclipse.emf.cdo.security.ui,
org.eclipse.emf.cdo.explorer,
org.eclipse.emf.cdo.explorer.ui",
- org.eclipse.emf.internal.cdo.session.remote;version="4.9.0";
+ org.eclipse.emf.internal.cdo.session.remote;version="4.9.1";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.ui",
- org.eclipse.emf.internal.cdo.transaction;version="4.9.0";
+ org.eclipse.emf.internal.cdo.transaction;version="4.9.1";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.ui,
org.eclipse.emf.cdo.explorer.ui",
- org.eclipse.emf.internal.cdo.util;version="4.9.0";
+ org.eclipse.emf.internal.cdo.util;version="4.9.1";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
org.eclipse.emf.cdo.ui",
- org.eclipse.emf.internal.cdo.view;version="4.9.0";
+ org.eclipse.emf.internal.cdo.view;version="4.9.1";
x-friends:="org.eclipse.emf.cdo.net4j,
org.eclipse.emf.cdo.server,
org.eclipse.emf.cdo.tests,
@@ -79,6 +79,6 @@ Export-Package: org.eclipse.emf.cdo;version="4.9.0",
org.eclipse.emf.cdo.ui.ide,
org.eclipse.emf.cdo.explorer,
org.eclipse.emf.cdo.explorer.ui",
- org.eclipse.emf.spi.cdo;version="4.9.0"
+ org.eclipse.emf.spi.cdo;version="4.9.1"
Bundle-ActivationPolicy: lazy
Automatic-Module-Name: org.eclipse.emf.cdo
diff --git a/plugins/org.eclipse.emf.cdo/pom.xml b/plugins/org.eclipse.emf.cdo/pom.xml
index 8ecc96485d..315ed09c2a 100644
--- a/plugins/org.eclipse.emf.cdo/pom.xml
+++ b/plugins/org.eclipse.emf.cdo/pom.xml
@@ -25,7 +25,7 @@
<groupId>org.eclipse.emf.cdo</groupId>
<artifactId>org.eclipse.emf.cdo</artifactId>
- <version>4.9.0-SNAPSHOT</version>
+ <version>4.9.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
index e4dfd8d270..58a1ab2424 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/AbstractCDOView.java
@@ -164,6 +164,8 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
protected final Condition viewLockCondition;
+ private final BranchPointLock branchPointLock = new BranchPointLock();
+
private CDOBranchPoint branchPoint;
private CDOBranchPoint normalizedBranchPoint;
@@ -275,18 +277,9 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
@Override
public boolean isHistorical()
{
- synchronized (getViewMonitor())
+ synchronized (branchPointLock)
{
- lockView();
-
- try
- {
- return branchPoint.getTimeStamp() != CDOBranchPoint.UNSPECIFIED_DATE;
- }
- finally
- {
- unlockView();
- }
+ return branchPoint.getTimeStamp() != CDOBranchPoint.UNSPECIFIED_DATE;
}
}
@@ -760,108 +753,42 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
protected CDOBranchPoint getBranchPoint()
{
- synchronized (getViewMonitor())
+ synchronized (branchPointLock)
{
- lockView();
-
- try
- {
- return branchPoint;
- }
- finally
- {
- unlockView();
- }
+ return branchPoint;
}
}
protected CDOBranchPoint getNormalizedBranchPoint()
{
- synchronized (getViewMonitor())
+ synchronized (branchPointLock)
{
- lockView();
-
- try
- {
- return normalizedBranchPoint;
- }
- finally
- {
- unlockView();
- }
+ return normalizedBranchPoint;
}
}
@Override
public boolean setBranch(CDOBranch branch)
{
- synchronized (getViewMonitor())
- {
- lockView();
-
- try
- {
- return setBranchPoint(branch, getTimeStamp(), null);
- }
- finally
- {
- unlockView();
- }
- }
+ return setBranchPoint(branch, getTimeStamp(), null);
}
@Override
public boolean setBranch(CDOBranch branch, IProgressMonitor monitor)
{
- synchronized (getViewMonitor())
- {
- lockView();
-
- try
- {
- return setBranchPoint(branch, getTimeStamp(), monitor);
- }
- finally
- {
- unlockView();
- }
- }
+ return setBranchPoint(branch, getTimeStamp(), monitor);
}
@Override
public boolean setTimeStamp(long timeStamp)
{
- synchronized (getViewMonitor())
- {
- lockView();
-
- try
- {
- return setBranchPoint(getBranch(), timeStamp, null);
- }
- finally
- {
- unlockView();
- }
- }
+ return setBranchPoint(getBranch(), timeStamp, null);
}
@Override
public boolean setTimeStamp(long timeStamp, IProgressMonitor monitor)
{
- synchronized (getViewMonitor())
- {
- lockView();
-
- try
- {
- return setBranchPoint(getBranch(), timeStamp, monitor);
- }
- finally
- {
- unlockView();
- }
- }
+ return setBranchPoint(getBranch(), timeStamp, monitor);
}
@Override
@@ -885,20 +812,11 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
protected CDOBranchPoint basicSetBranchPoint(CDOBranchPoint branchPoint)
{
- synchronized (getViewMonitor())
+ synchronized (branchPointLock)
{
- lockView();
-
- try
- {
- this.branchPoint = adjustBranchPoint(branchPoint);
- normalizedBranchPoint = CDOBranchUtil.normalizeBranchPoint(this.branchPoint);
- return this.branchPoint;
- }
- finally
- {
- unlockView();
- }
+ this.branchPoint = adjustBranchPoint(branchPoint);
+ normalizedBranchPoint = CDOBranchUtil.normalizeBranchPoint(this.branchPoint);
+ return this.branchPoint;
}
}
@@ -923,36 +841,18 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
@Override
public CDOBranch getBranch()
{
- synchronized (getViewMonitor())
+ synchronized (branchPointLock)
{
- lockView();
-
- try
- {
- return branchPoint.getBranch();
- }
- finally
- {
- unlockView();
- }
+ return branchPoint.getBranch();
}
}
@Override
public long getTimeStamp()
{
- synchronized (getViewMonitor())
+ synchronized (branchPointLock)
{
- lockView();
-
- try
- {
- return branchPoint.getTimeStamp();
- }
- finally
- {
- unlockView();
- }
+ return branchPoint.getTimeStamp();
}
}
@@ -2986,17 +2886,18 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
builder.append(" "); //$NON-NLS-1$
builder.append(getViewID());
- if (branchPoint != null)
+ CDOBranchPoint bp = branchPoint;
+ if (bp != null)
{
boolean brackets = false;
if (getSession().getRepositoryInfo().isSupportingBranches())
{
brackets = true;
builder.append(" ["); //$NON-NLS-1$
- builder.append(branchPoint.getBranch().getPathName()); // Do not synchronize on this view!
+ builder.append(bp.getBranch().getPathName()); // Do not synchronize on this view!
}
- long timeStamp = branchPoint.getTimeStamp(); // Do not synchronize on this view!
+ long timeStamp = bp.getTimeStamp(); // Do not synchronize on this view!
if (timeStamp != CDOView.UNSPECIFIED_DATE)
{
if (brackets)
@@ -3120,9 +3021,10 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
LifecycleUtil.activate(viewLock);
- if (branchPoint != null)
+ CDOBranchPoint bp = branchPoint;
+ if (bp != null)
{
- basicSetBranchPoint(branchPoint);
+ basicSetBranchPoint(bp);
}
}
@@ -3388,6 +3290,15 @@ public abstract class AbstractCDOView extends CDOCommitHistoryProviderImpl<CDOOb
*
* @author Eike Stepper
*/
+ private static final class BranchPointLock
+ {
+ }
+
+ /**
+ * For better debugging.
+ *
+ * @author Eike Stepper
+ */
private static final class NOOPMonitor
{
}

Back to the top