Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-09-17 11:30:27 +0000
committerEike Stepper2010-09-17 11:30:27 +0000
commit3106cea08140b348ddf6afe144c46887b85237b3 (patch)
tree0d057294c65aa76ee99392fa54f40b9fd995a750
parent90317aa6758bfee3128a4e2d7d795f90531ea4a0 (diff)
downloadcdo-3106cea08140b348ddf6afe144c46887b85237b3.tar.gz
cdo-3106cea08140b348ddf6afe144c46887b85237b3.tar.xz
cdo-3106cea08140b348ddf6afe144c46887b85237b3.zip
[325549] Synchronizable repository: order of commits is not ensured (CommitRunnable / WriteThroughCommitContext)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=325549
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java
index 7359e4adee..c3bb10ede7 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/syncing/SynchronizableRepository.java
@@ -59,6 +59,9 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
/**
* TODO:
@@ -107,8 +110,15 @@ public abstract class SynchronizableRepository extends Repository.Default implem
private int lastTransactionID;
+ private ReadLock writeThroughCommitLock;
+
+ private WriteLock handleCommitInfoLock;
+
public SynchronizableRepository()
{
+ ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
+ writeThroughCommitLock = rwLock.readLock();
+ handleCommitInfoLock = rwLock.writeLock();
}
public InternalRepositorySynchronizer getSynchronizer()
@@ -205,6 +215,8 @@ public abstract class SynchronizableRepository extends Repository.Default implem
try
{
+ handleCommitInfoLock.lock();
+
commitContext.write(new Monitor());
commitContext.commit(new Monitor());
@@ -214,6 +226,7 @@ public abstract class SynchronizableRepository extends Repository.Default implem
}
finally
{
+ handleCommitInfoLock.unlock();
commitContext.postCommit(success);
transaction.close();
}
@@ -508,10 +521,19 @@ public abstract class SynchronizableRepository extends Repository.Default implem
addIDMappings(result.getIDMappings());
applyIDMappings(new Monitor());
- // Commit to the local repository
- super.preWrite();
- super.write(new Monitor());
- super.commit(new Monitor());
+ try
+ {
+ writeThroughCommitLock.lock();
+
+ // Commit to the local repository
+ super.preWrite();
+ super.write(new Monitor());
+ super.commit(new Monitor());
+ }
+ finally
+ {
+ writeThroughCommitLock.unlock();
+ }
// Remember commit time in the local repository
setLastCommitTimeStamp(timeStamp);

Back to the top