keith-turner commented on a change in pull request #2467:
URL: https://github.com/apache/accumulo/pull/2467#discussion_r801847709



##########
File path: core/src/main/java/org/apache/accumulo/fate/Fate.java
##########
@@ -71,24 +83,51 @@ public void run() {
         try {
           tid = store.reserve();
           TStatus status = store.getStatus(tid);
+          if (status == FAILED) {
+            runnerLog.info(
+                "FATE txid " + Long.toHexString(tid) + " likely cancelled 
before it started.");
+            return;
+          }
           Repo<T> op = store.top(tid);
-          if (status == TStatus.FAILED_IN_PROGRESS) {
+          if (status == FAILED_IN_PROGRESS) {
             processFailed(tid, op);
           } else {
             Repo<T> prevOp = null;
+            boolean exceptionSeen = false;
             try {
-              deferTime = op.isReady(tid, environment);
-
-              if (deferTime == 0) {
-                prevOp = op;
-                if (status == TStatus.SUBMITTED) {
-                  store.setStatus(tid, TStatus.IN_PROGRESS);
+              try {
+                synchronized (RUNNING_TRANSACTIONS) {
+                  RUNNING_TRANSACTIONS.put(tid, Thread.currentThread());

Review comment:
       ```suggestion
                     // If this ever fails its indication that there is a 
concurrency problem in other code because its not  expected that multiple 
threads would be working on the same transaction id at the same time.
                     
Preconditions.checkState(RUNNING_TRANSACTIONS.putIfAbsent(tid,Thread.currentThread())
 == null);
   ```

##########
File path: core/src/main/java/org/apache/accumulo/fate/Fate.java
##########
@@ -71,24 +83,51 @@ public void run() {
         try {
           tid = store.reserve();
           TStatus status = store.getStatus(tid);
+          if (status == FAILED) {
+            runnerLog.info(
+                "FATE txid " + Long.toHexString(tid) + " likely cancelled 
before it started.");
+            return;
+          }
           Repo<T> op = store.top(tid);
-          if (status == TStatus.FAILED_IN_PROGRESS) {
+          if (status == FAILED_IN_PROGRESS) {
             processFailed(tid, op);
           } else {
             Repo<T> prevOp = null;
+            boolean exceptionSeen = false;
             try {
-              deferTime = op.isReady(tid, environment);
-
-              if (deferTime == 0) {
-                prevOp = op;
-                if (status == TStatus.SUBMITTED) {
-                  store.setStatus(tid, TStatus.IN_PROGRESS);
+              try {
+                synchronized (RUNNING_TRANSACTIONS) {
+                  RUNNING_TRANSACTIONS.put(tid, Thread.currentThread());
                 }
-                op = op.call(tid, environment);
-              } else
-                continue;
-
+                deferTime = op.isReady(tid, environment);
+                if (deferTime == 0) {
+                  prevOp = op;
+                  if (status == SUBMITTED) {
+                    store.setStatus(tid, IN_PROGRESS);
+                  }
+                  op = op.call(tid, environment);
+                } else
+                  continue;
+              } catch (Exception e) {
+                exceptionSeen = true;
+                throw e;
+              } finally {
+                synchronized (RUNNING_TRANSACTIONS) {
+                  RUNNING_TRANSACTIONS.remove(tid);

Review comment:
       ```suggestion
                     // unexpected that the following should fail, if it does 
probably indicates there is a semantic error in the code
                     Preconditions.checkState(RUNNING_TRANSACTIONS.remove(tid) 
!= null);
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to