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 10:13:17 UTC

[GitHub] [incubator-doris] imay commented on a change in pull request #934: Move lock of routine load job

imay commented on a change in pull request #934: Move lock of routine load job
URL: https://github.com/apache/incubator-doris/pull/934#discussion_r275725875
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/transaction/GlobalTransactionMgr.java
 ##########
 @@ -360,39 +360,18 @@ public void commitTransaction(long dbId, long transactionId, List<TabletCommitIn
                 }
             }
         }
-        
+
+        // before state transform
+        transactionState.beforeStateTransform(TransactionStatus.COMMITTED);
+        // transaction state transform
         writeLock();
         try {
-            // transaction state is modified during check if the transaction could committed
-            if (transactionState.getTransactionStatus() != TransactionStatus.PREPARE) {
-                return;
-            }
-            // 4. update transaction state version
-            transactionState.setCommitTime(System.currentTimeMillis());
-            transactionState.setTransactionStatus(TransactionStatus.COMMITTED);
-            transactionState.setErrorReplicas(errorReplicaIds);
-            for (long tableId : tableToPartition.keySet()) {
-                TableCommitInfo tableCommitInfo = new TableCommitInfo(tableId);
-                for (long partitionId : tableToPartition.get(tableId)) {
-                    OlapTable table = (OlapTable) db.getTable(tableId);
-                    Partition partition = table.getPartition(partitionId);
-                    PartitionCommitInfo partitionCommitInfo = new PartitionCommitInfo(partitionId,
-                                                                                      partition.getNextVersion(),
-                                                                                      partition.getNextVersionHash());
-                    tableCommitInfo.addPartitionCommitInfo(partitionCommitInfo);
-                }
-                transactionState.putIdToTableCommitInfo(tableId, tableCommitInfo);
-            }
-            // 5. persistent transactionState
-            unprotectUpsertTransactionState(transactionState);
-            
-            // add publish version tasks. set task to null as a placeholder.
-            // tasks will be created when publishing version.
-            for (long backendId : totalInvolvedBackends) {
-                transactionState.addPublishVersionTask(backendId, null);
-            }
+            unprotectedCommitTransaction(transactionState, errorReplicaIds, tableToPartition, totalInvolvedBackends,
+                                         db);
         } finally {
             writeUnlock();
+            // after state transform
+            transactionState.afterStateTransform(TransactionStatus.COMMITTED);
 
 Review comment:
   If fail to commit, call `afterStateTransform` with COMMITTED is OK? 

----------------------------------------------------------------
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