github-actions[bot] commented on code in PR #62058:
URL: https://github.com/apache/doris/pull/62058#discussion_r3031248481


##########
be/src/storage/rowset_builder.cpp:
##########
@@ -417,5 +475,93 @@ Status BaseRowsetBuilder::_build_current_tablet_schema(
             table_schema_param->sequence_map_col_uid(), 
_max_version_in_flush_phase));
     return Status::OK();
 }
+
+GroupRowsetBuilder::GroupRowsetBuilder(StorageEngine& engine, const 
WriteRequest& req,
+                                       const WriteRequest& row_binlog_req, 
RuntimeProfile* profile)
+        : BaseRowsetBuilder(
+                  [](int64_t tablet_id) {
+                      WriteRequest group_req;
+                      group_req.tablet_id = tablet_id;
+                      group_req.write_req_type = WriteRequestType::GROUP;
+                      return group_req;
+                  }(req.tablet_id),
+                  profile) {
+    _row_binlog_rowset_builder =
+            std::make_shared<RowBinlogRowsetBuilder>(engine, row_binlog_req, 
profile);
+    _txn_rs_builder = std::make_shared<RowsetBuilder>(engine, req, profile);
+}
+
+Status GroupRowsetBuilder::init() {
+    // init binlog builder first so that its rowset id can be added into
+    // PendingLocalRowsets before txn builder init.
+    RETURN_IF_ERROR(_row_binlog_rowset_builder->init());
+    // before init txn, need to add all rowset_ids into PendingLocalRowsets.
+    // see https://github.com/apache/doris/pull/25921
+    RETURN_IF_ERROR(_txn_rs_builder->attach_pending_rs_guard_to_txn(
+            _row_binlog_rowset_builder->rowset_id()));
+    RETURN_IF_ERROR(_txn_rs_builder->init());
+
+    // Create a GroupRowsetWriter that forwards flush to both underlying
+    // RowsetWriters.
+    std::unique_ptr<doris::GroupRowsetWriter> group_writer;
+    
RETURN_IF_ERROR(RowsetFactory::create_empty_group_rowset_writer(&group_writer));
+    group_writer->set_data_writer(_txn_rs_builder->rowset_writer());
+    
group_writer->set_row_binlog_writer(_row_binlog_rowset_builder->rowset_writer());
+
+    _rowset_writer = std::move(group_writer);
+    _is_init = true;
+    return Status::OK();
+}
+
+Status GroupRowsetBuilder::submit_calc_delete_bitmap_task() {
+    return _txn_rs_builder->submit_calc_delete_bitmap_task();
+}
+
+Status GroupRowsetBuilder::wait_calc_delete_bitmap() {
+    return _txn_rs_builder->wait_calc_delete_bitmap();
+}
+
+Status GroupRowsetBuilder::commit_txn() {
+    // Attach binlog rowset to txn rowset, so that commit/rollback and
+    // clean-up are all handled by txn rowset builder.
+    
RETURN_IF_ERROR(_txn_rs_builder->attach_rowset_to_txn(_row_binlog_rowset_builder->rowset()));
+    return _txn_rs_builder->commit_txn();

Review Comment:
   This does not actually make the row-binlog rowset part of the txn publish 
path. At this point the extra rowset only lives in `_attach_rowsets`, but 
`TxnManager::commit_txn()` / `TabletTxnInfo` still persist exactly one 
`rowset`, and `publish_version_and_add_rowset()` later publishes exactly one 
rowset via `tablet->add_inc_rowset(rowset)`. So in the normal load path the 
data rowset becomes visible, while the companion row-binlog rowset is never 
saved/published into tablet metadata. A BE restart before publish also loses 
it, because only the data rowset meta is written to RocksDB. The txn state 
needs to carry and publish both rowsets atomically.



##########
be/src/storage/tablet/tablet.cpp:
##########
@@ -1918,18 +1945,57 @@ Status Tablet::create_initial_rowset(const int64_t 
req_version) {
                 "init version of tablet should at least 1. req.ver={}", 
req_version);
     }
     Version version(0, req_version);
-    RowsetSharedPtr new_rowset;
-    // there is no data in init rowset, so overlapping info is unknown.
-    RowsetWriterContext context;
-    context.version = version;
-    context.rowset_state = VISIBLE;
-    context.segments_overlap = OVERLAP_UNKNOWN;
-    context.tablet_schema = tablet_schema();
-    context.newest_write_timestamp = UnixSeconds();
-    auto rs_writer = DORIS_TRY(create_rowset_writer(context, false));
-    RETURN_IF_ERROR(rs_writer->flush());
-    RETURN_IF_ERROR(rs_writer->build(new_rowset));
-    RETURN_IF_ERROR(add_rowset(std::move(new_rowset)));
+
+    auto get_rowset_writer_context = [&](RowsetWriterContext& context, 
TabletSchemaSPtr schema) {
+        // there is no data in init rowset, so overlapping info is unknown.
+        context.version = version;
+        context.rowset_state = VISIBLE;
+        context.segments_overlap = OVERLAP_UNKNOWN;
+        context.tablet_schema = schema;
+        context.newest_write_timestamp = UnixSeconds();
+
+        return Status::OK();
+    };
+
+    if (!enable_row_binlog()) {
+        RowsetWriterContext context;
+        RowsetSharedPtr new_rowset;
+        RETURN_IF_ERROR(get_rowset_writer_context(context, tablet_schema()));
+        auto rs_writer = DORIS_TRY(create_rowset_writer(context, false));
+
+        RETURN_IF_ERROR(rs_writer->flush());
+        RETURN_IF_ERROR(rs_writer->build(new_rowset));
+        RETURN_IF_ERROR(add_rowset(std::move(new_rowset), nullptr));
+    } else {
+        std::unique_ptr<GroupRowsetWriter> group_rowset_writer;
+        
RETURN_IF_ERROR(RowsetFactory::create_empty_group_rowset_writer(&group_rowset_writer));
+
+        RowsetWriterContext data_context;
+        data_context.write_binlog_opt().mark_primary_writer();
+        RETURN_IF_ERROR(get_rowset_writer_context(data_context, 
tablet_schema()));
+        auto data_writer = DORIS_TRY(create_rowset_writer(data_context, 
false));
+        group_rowset_writer->set_data_writer(std::move(data_writer));
+
+        RowsetWriterContext row_binlog_context;
+        row_binlog_context.write_binlog_opt().mark_binlog_writer();
+        RETURN_IF_ERROR(get_rowset_writer_context(row_binlog_context, 
tablet_schema()));
+        auto row_binlog_writer = 
DORIS_TRY(create_rowset_writer(row_binlog_context, false));

Review Comment:
   The initial row-binlog rowset is being built with `tablet_schema()` here 
instead of `row_binlog_tablet_schema()`. `_init_context_common_fields()` later 
switches only the schema hash/path for binlog writers, so the resulting 
version-1 row-binlog rowset meta still carries the base-table schema (missing 
the hidden binlog columns) under the row-binlog schema hash. Because rowsets 
reconstruct their schema from their own meta, this leaves the bootstrap 
row-binlog rowset inconsistent from creation time onward.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to