kangkaisen commented on a change in pull request #3196: Support determine 
isPreviousLoadFinished for some alter jobs in table level 
URL: https://github.com/apache/incubator-doris/pull/3196#discussion_r398550613
 
 

 ##########
 File path: 
fe/src/main/java/org/apache/doris/transaction/GlobalTransactionMgr.java
 ##########
 @@ -802,25 +802,38 @@ public void finishTransaction(long transactionId, 
Set<Long> errorReplicaIds) thr
     }
     
     // check if there exists a load job before the endTransactionId have all 
finished
-    // load job maybe started but could not know the affected table id, so 
that we not check by table
-    public boolean isPreviousTransactionsFinished(long endTransactionId, long 
dbId) {
-        readLock();
-        try {
-            for (Map.Entry<Long, TransactionState> entry : 
idToTransactionState.entrySet()) {
-                if (entry.getValue().getDbId() != dbId || 
!entry.getValue().isRunning()) {
-                    continue;
-                }
-                if (entry.getKey() <= endTransactionId) {
-                    LOG.debug("find a running txn with txn_id={} on db: {}, 
less than watermark txn_id {}",
-                            entry.getKey(), dbId, endTransactionId);
-                    return false;
-                }
+    public boolean isPreviousTransactionsFinished(long endTransactionId, long 
dbId, List<Long> tableIdList) {
+        for (Map.Entry<Long, TransactionState> entry : 
idToTransactionState.entrySet()) {
+            if (entry.getValue().getDbId() != dbId || 
!isIntersectionNotEmpty(entry.getValue().getTableIdList(),
+                    tableIdList) || !entry.getValue().isRunning()) {
+                continue;
+            }
+            if (entry.getKey() <= endTransactionId) {
+                LOG.debug("find a running txn with txn_id={} on db: {}, less 
than watermark txn_id {}",
+                        entry.getKey(), dbId, endTransactionId);
+                return false;
             }
-        } finally {
-            readUnlock();
         }
         return true;
     }
+
+    // check if there exists a intersection between the source tableId list 
and target tableId list
+    // if one of them is null or empty, that means that we don't know related 
tables in tableList,
+    // we think the two lists may have intersection for right ordered txns
+    public boolean isIntersectionNotEmpty(List<Long> sourceTableIdList, 
List<Long> targetTableIdList) {
+        if (sourceTableIdList == null || sourceTableIdList.isEmpty() || 
targetTableIdList == null ||
 
 Review comment:
   could use `CollectionUtils.isEmpty`

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to