Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-03-24 07:04:08 +0000
committerEike Stepper2020-03-24 07:04:08 +0000
commit850a75fe1a44b4245f4bcffcfd9d7e8b49746e8d (patch)
treeedca06b7609e2e3a05599a0627a3db6b68782515
parent5b64b0eb7410e420c6d1cc86d815297873ddfcc9 (diff)
downloadcdo-850a75fe1a44b4245f4bcffcfd9d7e8b49746e8d.tar.gz
cdo-850a75fe1a44b4245f4bcffcfd9d7e8b49746e8d.tar.xz
cdo-850a75fe1a44b4245f4bcffcfd9d7e8b49746e8d.zip
[560957] Deadlock when using CDOMergingConflictResolver
https://bugs.eclipse.org/bugs/show_bug.cgi?id=560957
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_560957_Test.java52
1 files changed, 43 insertions, 9 deletions
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
index 9bec13af9e..7e17f5803c 100644
--- 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
@@ -15,8 +15,11 @@ 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.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.ConcurrentAccessException;
import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.concurrent.TimeoutRuntimeException;
import java.util.concurrent.CountDownLatch;
@@ -27,16 +30,30 @@ import java.util.concurrent.CountDownLatch;
*/
public class Bugzilla_560957_Test extends AbstractCDOTest
{
+ public void testDeadlockOnViewGetBranch10000() throws Exception
+ {
+ for (int i = 0; i < 100; i++)
+ {
+ System.out.println("Run " + i);
+ run(i);
+ }
+ }
+
public void testDeadlockOnViewGetBranch() throws Exception
{
+ run(1);
+ }
+
+ private void run(int run) throws ConcurrentAccessException, CommitException
+ {
CDOSession session = openSession();
CDOTransaction transaction1 = session.openTransaction();
- transaction1.createResource(getResourcePath("resource" + transaction1.getViewID()));
+ transaction1.createResource(getResourcePath("resource-" + run + "-" + transaction1.getViewID()));
transaction1.commit();
CDOTransaction transaction2 = session.openTransaction();
- transaction2.createResource(getResourcePath("resource" + transaction2.getViewID()));
+ transaction2.createResource(getResourcePath("resource-" + run + "-" + transaction2.getViewID()));
transaction2.commit();
CountDownLatch allThreadsCalledCommit = new CountDownLatch(2);
@@ -68,7 +85,7 @@ public class Bugzilla_560957_Test extends AbstractCDOTest
public void run()
{
// Make transaction dirty.
- CDOResource resource = transaction.getResource(getResourcePath("resource" + transaction.getViewID()));
+ CDOResource resource = transaction.getResource(getResourcePath("resource-" + run + "-" + transaction.getViewID()));
resource.getContents().add(getModel1Factory().createCompany());
try
@@ -85,18 +102,35 @@ public class Bugzilla_560957_Test extends AbstractCDOTest
private void sessionInvalidated()
{
- allThreadsCalledCommit.countDown();
- await(allThreadsCalledCommit);
+ if (getName().equals(currentThread().getName()))
+ {
+ allThreadsCalledCommit.countDown();
- // Call the methods on the other transaction that can lead to deadlock.
- otherTransaction.getBranch();
- otherTransaction.getTimeStamp();
- otherTransaction.isHistorical();
+ try
+ {
+ await(allThreadsCalledCommit, 1000);
+ }
+ catch (TimeoutRuntimeException ex)
+ {
+ // The await() call in the above try-block is not normal client code.
+ // It rather tries to produce a very specific timing that's needed for the test logic.
+ // It also creates an unusual coupling between the two committing clients that can cause
+ // an unusual race condition in SessionInvalidator.scheduleInvalidations().
+ // As this is not a situation that can occur in real clients and not the one we want to
+ // test here we'll just ignore it and go on...
+ }
+
+ // 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);
+ session.close();
}
}

Back to the top