Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-02-22 09:28:24 +0000
committerEike Stepper2020-02-22 09:28:24 +0000
commit0927747b99bcd0de1ea42369dd98fe527bbd795d (patch)
treeff8ca1e1c48e9b230c9ec8cf88569d48a33ab54b
parent7d10d7c9d86eb2cad9ed5ac6df60bcb7a5f71b39 (diff)
downloadcdo-0927747b99bcd0de1ea42369dd98fe527bbd795d.tar.gz
cdo-0927747b99bcd0de1ea42369dd98fe527bbd795d.tar.xz
cdo-0927747b99bcd0de1ea42369dd98fe527bbd795d.zip
[560280] Possible deadlock during the session invalidation
https://bugs.eclipse.org/bugs/show_bug.cgi?id=560280
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_560280_Test.java43
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java5
2 files changed, 28 insertions, 20 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_560280_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_560280_Test.java
index a9979ef1df..f7112415dd 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_560280_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_560280_Test.java
@@ -10,6 +10,7 @@
*/
package org.eclipse.emf.cdo.tests.bugzilla;
+import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.revision.CDORevision;
import org.eclipse.emf.cdo.common.security.CDOPermission;
@@ -30,6 +31,7 @@ import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.view.CDOView;
@@ -38,13 +40,12 @@ import org.eclipse.net4j.util.security.IPasswordCredentials;
import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
import org.eclipse.net4j.util.security.PasswordCredentials;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
-import org.eclipse.emf.spi.cdo.InternalCDOView;
import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
/**
* Bug 560280 - Possible deadlock during the session invalidation.
@@ -85,12 +86,13 @@ public class Bugzilla_560280_Test extends AbstractCDOTest
public void testDeadlockBetweenInvalidationAndCommit() throws Exception
{
- CDOSession session1 = openSession();
- CDOTransaction transaction1 = session1.openTransaction();
- Realm realm1 = getRealm(transaction1);
- Group group1 = realm1.getGroup("Users");
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ Realm realm = getRealm(transaction);
+ Group groupToBeChanged = realm.getGroup("Users");
+ Group groupToBeDeleted = realm.addGroup("GroupToBeDeleted");
+ transaction.commit(); // Commit "GroupToBeDeleted".
- AtomicReference<CDOTransaction> transactionUnderTest = new AtomicReference<>();
AtomicBoolean controlUpdatePermissions = new AtomicBoolean();
CountDownLatch reachedUpdatePermissions = new CountDownLatch(1);
CountDownLatch allowUpdatePermissions = new CountDownLatch(1);
@@ -103,7 +105,7 @@ public class Bugzilla_560280_Test extends AbstractCDOTest
return new CDONet4jSessionImpl()
{
@Override
- protected Map<CDORevision, CDOPermission> updatePermissions(CDOCommitInfo commitInfo, InternalCDOView[] views)
+ protected Map<CDORevision, CDOPermission> updatePermissions(CDOCommitInfo commitInfo)
{
if (controlUpdatePermissions.get())
{
@@ -111,7 +113,7 @@ public class Bugzilla_560280_Test extends AbstractCDOTest
await(allowUpdatePermissions);
}
- return super.updatePermissions(commitInfo, views);
+ return super.updatePermissions(commitInfo);
}
};
}
@@ -126,7 +128,8 @@ public class Bugzilla_560280_Test extends AbstractCDOTest
getTestProperties().put(SessionConfig.PROP_TEST_SESSION_CONFIGURATION, configuration);
CDOSession sessionUnderTest = openSession();
- transactionUnderTest.set(sessionUnderTest.openTransaction());
+ CDOTransaction transactionUnderTest = sessionUnderTest.openTransaction();
+ Group groupUnderTest = transactionUnderTest.getObject(groupToBeDeleted);
/*
* Test Logic:
@@ -134,10 +137,11 @@ public class Bugzilla_560280_Test extends AbstractCDOTest
controlUpdatePermissions.set(true);
- group1.setId("ModernUsers");
- transaction1.commit();
+ groupToBeChanged.setId("ModernUsers");
+ EcoreUtil.delete(groupToBeDeleted);
+ transaction.commit();
- // Execute transactionUndertTest.commit() on a separate thread so that the deadlock doesn't freeze the test suite.
+ // Execute transactionUnderTest.commit() on a separate thread so that the deadlock doesn't freeze the test suite.
CountDownLatch commitFinished = new CountDownLatch(1);
new Thread("CommitterUnderTest")
{
@@ -146,17 +150,15 @@ public class Bugzilla_560280_Test extends AbstractCDOTest
{
await(reachedUpdatePermissions);
- CDOTransaction tx = transactionUnderTest.get();
- tx.syncExec(() -> {
+ transactionUnderTest.syncExec(() -> {
allowUpdatePermissions.countDown();
try
{
- Realm realmUnderTest = getRealm(tx);
+ Realm realmUnderTest = getRealm(transactionUnderTest);
realmUnderTest.addUser("UserUnderTest", "abc");
- tx.commit();
- commitFinished.countDown();
+ transactionUnderTest.commit();
}
catch (CommitException ex)
{
@@ -164,6 +166,11 @@ public class Bugzilla_560280_Test extends AbstractCDOTest
ex.printStackTrace();
}
});
+
+ CDOObject cdoObject = CDOUtil.getCDOObject(groupUnderTest);
+ System.out.println("GroupToBeDeleted: " + cdoObject.cdoState());
+
+ commitFinished.countDown();
}
}.start();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
index b3907605c4..82277f3ddb 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/CDOSessionImpl.java
@@ -660,13 +660,14 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
return getBranchManager().getMainBranch();
}
- protected Map<CDORevision, CDOPermission> updatePermissions(CDOCommitInfo commitInfo, InternalCDOView[] views)
+ protected Map<CDORevision, CDOPermission> updatePermissions(CDOCommitInfo commitInfo)
{
CDOPermissionUpdater permissionUpdater = options().getPermissionUpdater();
if (permissionUpdater != null)
{
Set<InternalCDORevision> revisions = new HashSet<>();
revisionManager.getCache().forEachCurrentRevision(r -> revisions.add((InternalCDORevision)r));
+
return permissionUpdater.updatePermissions(CDOSessionImpl.this, revisions);
}
@@ -2101,7 +2102,7 @@ public abstract class CDOSessionImpl extends CDOTransactionContainerImpl impleme
if (invalidationData.getSecurityImpact() != CommitNotificationInfo.IMPACT_NONE)
{
- oldPermissions = updatePermissions(commitInfo, views);
+ oldPermissions = updatePermissions(commitInfo);
}
commitInfoManager.setLastCommitOfBranch(branch, timeStamp);

Back to the top