deardeng commented on code in PR #50343:
URL: https://github.com/apache/doris/pull/50343#discussion_r2060280036


##########
be/src/olap/task/engine_publish_version_task.cpp:
##########
@@ -396,6 +396,49 @@ TabletPublishTxnTask::TabletPublishTxnTask(StorageEngine& 
engine,
 
 TabletPublishTxnTask::~TabletPublishTxnTask() = default;
 
+Status publish_version_and_add_rowset(StorageEngine& engine, int64_t 
partition_id,
+                                      const TabletSharedPtr& tablet, const 
RowsetSharedPtr& rowset,
+                                      int64_t transaction_id, const Version& 
version,
+                                      EnginePublishVersionTask* 
engine_publish_version_task,
+                                      TabletPublishStatistics& stats) {
+    // ATTN: Here, the life cycle needs to be extended to prevent 
tablet_txn_info.pending_rs_guard in txn
+    // from being released prematurely, causing path gc to mistakenly delete 
the dat file
+    std::shared_ptr<TabletTxnInfo> extend_tablet_txn_info_lifetime = nullptr;
+
+    // Publish the transaction
+    auto result = engine.txn_manager()->publish_txn(partition_id, tablet, 
transaction_id, version,
+                                                    &stats, 
extend_tablet_txn_info_lifetime);
+    if (!result.ok()) {
+        LOG(WARNING) << "failed to publish version. rowset_id=" << 
rowset->rowset_id()
+                     << ", tablet_id=" << tablet->tablet_id() << ", txn_id=" 
<< transaction_id
+                     << ", res=" << result;
+        if (engine_publish_version_task) {
+            
engine_publish_version_task->add_error_tablet_id(tablet->tablet_id());
+        }
+        return result;
+    }
+
+    DBUG_EXECUTE_IF("EnginePublishVersionTask.handle.block_add_rowsets", 
DBUG_BLOCK);
+
+    // Add visible rowset to tablet
+    int64_t start_time = MonotonicMicros();
+    result = tablet->add_inc_rowset(rowset);
+    
DBUG_EXECUTE_IF("EnginePublishVersionTask.handle.after_add_inc_rowset_rowsets_block",
+                    DBUG_BLOCK);
+    stats.add_inc_rowset_us = MonotonicMicros() - start_time;
+    if (!result.ok() && !result.is<PUSH_VERSION_ALREADY_EXIST>()) {
+        LOG(WARNING) << "fail to add visible rowset to tablet. rowset_id=" << 
rowset->rowset_id()
+                     << ", tablet_id=" << tablet->tablet_id() << ", txn_id=" 
<< transaction_id
+                     << ", res=" << result;
+        if (engine_publish_version_task) {
+            
engine_publish_version_task->add_error_tablet_id(tablet->tablet_id());
+        }
+        return result;

Review Comment:
   useful



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