Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2018-02-23 17:07:37 +0000
committerRyan D. Brooks2023-01-16 20:48:04 +0000
commitc3d50219217235d6dc4bdad8f3eca12e64622e48 (patch)
tree4a1e4da098635040c34334b0d36797c790da39a1
parentbe64be8545a9db25e792b4374feb395c22e209b5 (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 956da1cf2f7..c6f1a2d3fb2 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 9e2f70c9b2f..52b0a358f3f 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.ArtifactReadable;
import org.eclipse.osee.framework.core.data.ArtifactTypeToken;
@@ -80,6 +84,7 @@ public class TxDataManager {
private final TupleDataFactory tupleFactory;
private final BranchCategoryDataFactory categoryFactory;
private final TxDataLoader loader;
+ private final ConcurrentMap<Long, Lock> hotBranches = new ConcurrentHashMap<>();
public TxDataManager(ExternalArtifactManager proxyManager, ArtifactFactory artifactFactory, RelationManager relationManager, TupleDataFactory tupleFactory, BranchCategoryDataFactory categoryFactory, TxDataLoader loader) {
this.proxyManager = proxyManager;
@@ -112,6 +117,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);
@@ -119,6 +128,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