You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2019/11/19 05:55:56 UTC

[GitHub] [incubator-doris] kangkaisen commented on a change in pull request #2222: Publish version immediately after txt commited

kangkaisen commented on a change in pull request #2222: Publish version immediately after txt commited
URL: https://github.com/apache/incubator-doris/pull/2222#discussion_r347742055
 
 

 ##########
 File path: fe/src/main/java/org/apache/doris/transaction/GlobalTransactionMgr.java
 ##########
 @@ -447,6 +447,115 @@ public void commitTransaction(long dbId, long transactionId, List<TabletCommitIn
         // 6. update nextVersion because of the failure of persistent transaction resulting in error version
         updateCatalogAfterCommitted(transactionState, db);
         LOG.info("transaction:[{}] successfully committed", transactionState);
+
+        // 7. try publishing version as soon as possible
+        if (couldPublishTransaction(transactionState)) {
+            publishTransaction(transactionState, totalInvolvedBackends);
+        } else {
+            // 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);
+            }
+        }
+    }
+
+    // the publishing transaction should meet:
+    // 1. the transaction state is COMMITTED
+    // 2. the partition's visible version plus one should equal transaction version.
+    public boolean couldPublishTransaction(TransactionState transactionState) {
+        Database db = catalog.getDb(transactionState.getDbId());
+        if (null == db) {
+            return false;
+        }
+
+        boolean meetPublishPredicate = true;
+        db.readLock();
+        try {
+            readLock();
+            try {
+                for (TableCommitInfo tableCommitInfo : transactionState.getIdToTableCommitInfos().values()) {
+                    OlapTable table = (OlapTable) db.getTable(tableCommitInfo.getTableId());
+                    if (null == table) {
 
 Review comment:
   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: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org