You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@doris.apache.org by GitBox <gi...@apache.org> on 2019/04/16 13:04:07 UTC

[GitHub] [incubator-doris] morningman commented on a change in pull request #938: Add error load log url for routine load job

morningman commented on a change in pull request #938: Add error load log url for routine load job
URL: https://github.com/apache/incubator-doris/pull/938#discussion_r275784606
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/load/routineload/RoutineLoadJob.java
 ##########
 @@ -574,32 +585,38 @@ public void beforeCommitted(TransactionState txnState) throws TransactionExcepti
         executeBeforeCheck(txnState, TransactionStatus.COMMITTED);
     }
 
+    /*
+     * try lock the write lock.
+     * Make sure lock is released if any exception being thrown
+     */
     private void executeBeforeCheck(TransactionState txnState, TransactionStatus transactionStatus)
             throws TransactionException {
+        if (!tryWriteLock(2000, TimeUnit.MILLISECONDS)) {
+            // The lock of job has been locked by another thread more then timeout seconds.
+            // The commit txn by thread2 will be failed after waiting for timeout seconds.
+            // Maybe thread1 hang on somewhere
+            LOG.warn(new LogBuilder(LogKey.ROUINTE_LOAD_TASK, txnState.getLabel()).add("job_id", id).add("txn_status",
+                    transactionStatus).add("error_msg",
+                            "txn could not be transformed while waiting for timeout of routine load job"));
+            throw new TransactionException("txn " + txnState.getTransactionId() + "could not be " + transactionStatus
+                    + "while waiting for timeout of routine load job.");
+        }
+
         // task already pass the checker
         try {
-            tryWriteLock();
             // check if task has been aborted
             Optional<RoutineLoadTaskInfo> routineLoadTaskInfoOptional =
-                    routineLoadTaskInfoList.parallelStream()
+                    routineLoadTaskInfoList.stream()
                             .filter(entity -> entity.getTxnId() == txnState.getTransactionId()).findFirst();
             if (!routineLoadTaskInfoOptional.isPresent()) {
-                writeUnlock();
+
                 throw new TransactionException("txn " + txnState.getTransactionId()
                                                        + " could not be " + transactionStatus
                                                        + " while task " + txnState.getLabel() + " has been aborted.");
             }
-        } catch (InterruptedException e) {
-            // The lock of job has been locked by thread1 more then timeout seconds.
-            // The commit txn by thread2 will be failed after waiting for timeout seconds.
-            // Maybe thread1 hang on somewhere
-            LOG.warn(new LogBuilder(LogKey.ROUINTE_LOAD_TASK, txnState.getLabel())
-                             .add("job_id", id)
-                             .add("txn_status", transactionStatus)
-                             .add("error_msg", "txn could not be transformed "
-                                     + "while waiting for timeout of routine load job"));
-            throw new TransactionException("txn " + txnState.getTransactionId() + "could not be " + transactionStatus
-                                                   + "while waiting for timeout of routine load job.", e);
+        } catch (Throwable e) {
 
 Review comment:
   Changed it to TransactionException

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@doris.apache.org
For additional commands, e-mail: dev-help@doris.apache.org