Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2018-02-23 12:07:37 -0500
committerRyan D. Brooks2019-08-22 18:03:18 -0400
commit1f8876be6f9fdd20a99e12d2402ce5d3d3346d45 (patch)
treef5976567798d2e7b6b9832d3000952c6cdac6f58
parent762718e4b7e9b2508b7f887836e291fc945fbfb3 (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 c2a2bd8c93..984bbf2f78 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
@@ -88,8 +88,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 864a5bd10d..432871d85f 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
@@ -19,6 +19,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;
@@ -73,6 +77,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;
@@ -104,6 +109,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);
@@ -111,6 +120,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