Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2018-02-23 17:07:37 +0000
committerRyan D. Brooks2020-06-23 17:41:43 +0000
commitac523e4567fec6bce26178c506caedd42746bd05 (patch)
treed9da3709b08eddd9dc078f0b87b88141806976d9
parent9b6de8fff9ea1e4dae11f80168ba07afec4b4d14 (diff)
downloadorg.eclipse.osee-rbrooks/dev.tar.gz
org.eclipse.osee-rbrooks/dev.tar.xz
org.eclipse.osee-rbrooks/dev.zip
bug: Safely handle concurrent transactions on serverrbrooks/dev
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxCallableFactory.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java11
2 files changed, 12 insertions, 2 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxCallableFactory.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxCallableFactory.java
index 3fb0909a8a5..ffe03be15d5 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxCallableFactory.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxCallableFactory.java
@@ -91,8 +91,7 @@ public class TxCallableFactory {
private TransactionResult doCommit() throws Exception {
TransactionData changes = txManager.createChangeData(txData);
- Callable<TransactionResult> callable = txDataStore.commitTransaction(getSession(), changes);
- return callable.call();
+ return txDataStore.commitTransaction(getSession(), changes).call();
}
};
}
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java
index 44dea6c9d25..457168b5e20 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/transaction/TxDataManager.java
@@ -22,6 +22,10 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import org.eclipse.osee.framework.core.data.ApplicabilityId;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.ArtifactTypeToken;
import org.eclipse.osee.framework.core.data.AttributeTypeToken;
@@ -76,6 +80,7 @@ public class TxDataManager {
private final RelationManager relationManager;
private final TupleDataFactory tupleFactory;
private final TxDataLoader loader;
+ private final ConcurrentMap<Long, Lock> hotBranches = new ConcurrentHashMap<>();
public TxDataManager(ExternalArtifactManager proxyManager, ArtifactFactory artifactFactory, RelationManager relationManager, TupleDataFactory tupleFactory, TxDataLoader loader) {
this.proxyManager = proxyManager;
@@ -107,6 +112,10 @@ public class TxDataManager {
}
public void startTx(TxData txData) {
+ Long branchId = txData.getBranchId();
+ hotBranches.putIfAbsent(branchId, new ReentrantLock());
+ Lock lock = hotBranches.get(branchId);
+ lock.lock();
Conditions.checkExpressionFailOnTrue(txData.isCommitInProgress(), "Commit is already in progress");
txData.setCommitInProgress(true);
txData.setTxState(TxState.COMMIT_STARTED);
@@ -114,6 +123,8 @@ public class TxDataManager {
public void endTx(TxData txData) {
txData.setCommitInProgress(false);
+ Lock lock = hotBranches.get(txData.getBranchId());
+ lock.unlock();
}
public Iterable<Artifact> getForWrite(TxData txData, Iterable<? extends ArtifactId> ids) {

Back to the top