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


##########
cloud/src/meta-service/txn_lazy_committer.cpp:
##########
@@ -0,0 +1,208 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "txn_lazy_committer.h"
+
+#include "common/logging.h"
+#include "common/util.h"
+#include "meta-service/keys.h"
+#include "meta-service/meta_service_helper.h"
+
+namespace doris::cloud {
+
+void scan_tmp_rowset(
+        const std::string& instance_id, int64_t txn_id, std::shared_ptr<TxnKv> 
txn_kv,
+        MetaServiceCode& code, std::string& msg, int64_t* db_id,
+        std::vector<std::pair<std::string, doris::RowsetMetaCloudPB>>* 
tmp_rowsets_meta);
+
+void convert_tmp_rowsets(
+        const std::string& instance_id, int64_t txn_id, std::shared_ptr<TxnKv> 
txn_kv,
+        MetaServiceCode& code, std::string& msg, int64_t db_id,
+        std::vector<std::pair<std::string, doris::RowsetMetaCloudPB>>& 
tmp_rowsets_meta,
+        std::unordered_map<int64_t, TabletIndexPB>& tablet_ids);
+
+void make_committed_txn_visible(const std::string& instance_id, int64_t db_id, 
int64_t txn_id,
+                                std::shared_ptr<TxnKv> txn_kv, 
MetaServiceCode& code,
+                                std::string& msg);
+
+TxnLazyCommitTask::TxnLazyCommitTask(const std::string& instance_id, int64_t 
txn_id,
+                                     std::shared_ptr<TxnKv> txn_kv,
+                                     TxnLazyCommitter* txn_lazy_committer)
+        : instance_id_(instance_id),
+          txn_id_(txn_id),
+          txn_kv_(txn_kv),
+          txn_lazy_committer_(txn_lazy_committer) {
+    DCHECK(txn_id > 0);
+}
+
+void TxnLazyCommitTask::commit() {
+    std::stringstream ss;
+    do {
+        code_ = MetaServiceCode::OK;
+        msg_.clear();
+        int64_t db_id;
+        std::vector<std::pair<std::string, doris::RowsetMetaCloudPB>> 
tmp_rowset_metas;
+        scan_tmp_rowset(instance_id_, txn_id_, txn_kv_, code_, msg_, &db_id, 
&tmp_rowset_metas);
+        if (code_ != MetaServiceCode::OK) {
+            LOG(WARNING) << "scan_tmp_rowset failed, txn_id=" << txn_id_ << " 
code=" << code_;
+            break;
+        }
+
+        VLOG_DEBUG << "txn_id=" << txn_id_
+                   << " tmp_rowset_metas.size()=" << tmp_rowset_metas.size();
+        if (tmp_rowset_metas.size() == 0) {
+            LOG(INFO) << "empty tmp_rowset_metas, txn_id=" << txn_id_;
+            break;

Review Comment:
   > Even if the tmp_rowset_metas is empty, the TXN might still not be visible. 
Consider call `make_committed_txn_visible` here.
   
   done, i have removed the `break`



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