SWJTU-ZhangLei commented on code in PR #40486:
URL: https://github.com/apache/doris/pull/40486#discussion_r1772955982


##########
cloud/src/meta-service/meta_service_txn.cpp:
##########
@@ -2529,18 +2554,31 @@ void 
MetaServiceImpl::commit_txn(::google::protobuf::RpcController* controller,
         return;
     }
 
-    if (request->has_is_2pc() && !request->is_2pc() && 
request->has_enable_txn_lazy_commit() &&
-        request->enable_txn_lazy_commit() && 
config::enable_cloud_txn_lazy_commit &&
-        (tmp_rowsets_meta.size() >= config::txn_lazy_commit_rowsets_thresold)) 
{
-        LOG(INFO) << "txn_id=" << txn_id << " commit_txn_eventually"
-                  << " size=" << tmp_rowsets_meta.size();
-        commit_txn_eventually(request, response, txn_kv_, txn_lazy_committer_, 
code, msg,
-                              instance_id, db_id, tmp_rowsets_meta);
-        return;
+    TxnErrorCode err = TxnErrorCode::TXN_OK;
+    bool allow_txn_lazy_commit =
+            (request->has_is_2pc() && !request->is_2pc() && 
request->has_enable_txn_lazy_commit() &&
+             request->enable_txn_lazy_commit() && 
config::enable_cloud_txn_lazy_commit);
+
+    if (!allow_txn_lazy_commit ||
+        (tmp_rowsets_meta.size() <= config::txn_lazy_commit_rowsets_thresold)) 
{
+        commit_txn_immediately(request, response, txn_kv_, 
txn_lazy_committer_, code, msg,
+                               instance_id, db_id, tmp_rowsets_meta, err);
+        if ((MetaServiceCode::OK == code) || 
(TxnErrorCode::TXN_BYTES_TOO_LARGE != err) ||
+            !allow_txn_lazy_commit) {
+            return;
+        }
+        DCHECK(code != MetaServiceCode::OK);
+        DCHECK(allow_txn_lazy_commit);
+        DCHECK(err == TxnErrorCode::TXN_BYTES_TOO_LARGE);
+        LOG(INFO) << "txn_id=" << txn_id << " fallthrough 
commit_txn_eventually";

Review Comment:
   > 简化一些这里的代码, 目前不太好理解. 按照下述条件来进行判断. 能走到eventual条件应该是以下其中之一:
   > 
   > 1. request显式set lazy = true 并且 不是2pc提交
   > 2. request没有lazy 字段并且config:enable_lazy 并且 rowset.size 超过 
conf:rowsets_thresold 并且 不是2pc提交
   > 3. request没有lazy 字段并且config:enable_lazy 并且 rowset.size 没超过 
conf:rowsets_thresold 但是immediate_commit失败 并且 不是2pc提交
   
   以上描述不对
   
   allow_txn_lazy_commit 代表是否能够允许lazy commit
   lazy commit只有两种情况:
   1、allow_txn_lazy_commit = true && tmp_rowsets_meta.size() > 
config::txn_lazy_commit_rowsets_thresold
   2、allow_txn_lazy_commit = true && tmp_rowsets_meta.size() <= 
config::txn_lazy_commit_rowsets_thresold && err = TXN_BYTES_TOO_LARGE
   
   
   



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to