Copilot commented on code in PR #62058:
URL: https://github.com/apache/doris/pull/62058#discussion_r3031253884
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowDataCommand.java:
##########
@@ -120,6 +123,7 @@ public class ShowDataCommand extends ShowCommand {
.addColumn(new Column("RemoteTotalSize",
ScalarType.createVarchar(30)))
.addColumn(new Column("RemoteDataSize",
ScalarType.createVarchar(30)))
.addColumn(new Column("RemoteIndexSize",
ScalarType.createVarchar(30)))
+ .addColumn(new Column("LocalBinlogSize",
ScalarType.createVarchar(30)))
.build();
Review Comment:
SHOW DATA detailed metadata labels the added column as `LocalBinlogSize`,
but the collected value is `mIndex.getBinlogDataSize()`, which sums
`Replica.getBinlogSize()` across all NORMAL replicas (i.e., total across
replicas), not a single-replica/local value. Either (a) change the label to
reflect total/replica-summed binlog size, or (b) change the computation to
single-replica binlog size (e.g., max across replicas) to match the existing
Local* semantics in detailed mode.
##########
be/src/storage/rowset_builder.cpp:
##########
@@ -212,7 +246,27 @@ Status RowsetBuilder::init() {
// build tablet schema in request level
RETURN_IF_ERROR(_build_current_tablet_schema(_req.index_id,
_req.table_schema_param.get(),
*_tablet->tablet_schema()));
- RowsetWriterContext context;
+
+ context.mow_context = mow_context;
+
+ context.partial_update_info = _partial_update_info;
+ _rowset_writer = DORIS_TRY(_tablet->create_rowset_writer(context, false));
+
+ std::vector<RowsetId> tmp_pending_rowset_ids = {_rowset_id};
+ tmp_pending_rowset_ids.resize(1 + _attach_rowset_ids.size());
+ std::copy(_attach_rowset_ids.begin(), _attach_rowset_ids.end(),
+ tmp_pending_rowset_ids.begin() + 1);
+ _pending_rs_guard =
_engine.pending_local_rowsets().add(tmp_pending_rowset_ids);
+
Review Comment:
RowsetBuilder::init() uses `_rowset_id` when registering pending rowsets,
but `_rowset_id` is never set from the actual `context.rowset_id` generated
inside `Tablet::create_rowset_writer()`. As written, PendingLocalRowsets is
populated with a default/invalid RowsetId, which can break pending rowset
cleanup and txn commit/rollback behavior (and group mode will also miss the
real data rowset id). Set `_rowset_id = context.rowset_id` (or read it from
`rowset_writer()->context().rowset_id`) after
`_tablet->create_rowset_writer(...)` returns, and use that value for
`tmp_pending_rowset_ids` (include attached ids as well).
##########
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()));
Review Comment:
In Tablet::create_initial_rowset() when row binlog is enabled, the
`row_binlog_context` is initialized with `tablet_schema()` (data schema).
Because `Tablet::_init_context_common_fields()` only overrides the schema
hash/path for binlog writers (not the `tablet_schema` pointer), the row binlog
rowset writer will be built using the wrong schema definition. Use
`row_binlog_tablet_schema()` (or `_tablet_meta->row_binlog_schema()`) when
populating `row_binlog_context.tablet_schema`.
```suggestion
RETURN_IF_ERROR(
get_rowset_writer_context(row_binlog_context,
row_binlog_tablet_schema()));
```
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/Replica.java:
##########
@@ -105,6 +107,9 @@ public static class ReplicaContext {
@SerializedName(value = "lss", alternate = {"localSegmentSize"})
private long localSegmentSize = 0L;
+ // Number of binlog files retained on this replica.
+ private volatile long binlogFileNum = -1;
+
Review Comment:
Replica adds `binlogFileNum` as a new Gson-persisted field but it lacks
`@SerializedName` (unlike other persisted fields that use short keys +
alternates for backward compatibility). This will bloat persisted JSON and
misses a stable short-key mapping. Add `@SerializedName` with a short key (and
optionally an alternate legacy name) similar to `dataSize`/`binlogSize`.
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTableWrapper.java:
##########
@@ -0,0 +1,140 @@
+// 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.
+
+package org.apache.doris.catalog;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A lightweight wrapper base class for {@link OlapTable}.
+ *
+ * <p>It delegates table locks and partition-related operations to the wrapped
table to keep the
+ * metadata view consistent.
+ */
+public class OlapTableWrapper extends OlapTable {
+
+ protected final OlapTable originTable;
+
+ protected OlapTableWrapper(OlapTable originTable, String wrapperName,
List<Column> baseSchema, KeysType keysType) {
+ super(originTable.getId(), wrapperName + "_" + originTable.getName(),
baseSchema,
+ keysType, originTable.getPartitionInfo(),
originTable.getDefaultDistributionInfo());
+ this.originTable = originTable;
Review Comment:
OlapTableWrapper constructs the wrapper table name as `wrapperName + "_" +
originTable.getName()`. RowBinlogTableWrapper already passes a wrapperName that
includes the origin table name (e.g. `binlog<Row>(tbl)`), so the resulting
table name becomes duplicated (e.g. `binlog<Row>(tbl)_tbl`). Consider making
the wrapper name the final name (no automatic suffix), or require wrapperName
to be a pure prefix to avoid double-including the origin name.
##########
be/src/storage/tablet/tablet.h:
##########
@@ -468,13 +480,29 @@ class Tablet final : public BaseTablet {
int64_t get_table_id() { return _tablet_meta->table_id(); }
// binlog related functions
- bool is_enable_binlog();
- bool is_binlog_enabled() { return
_tablet_meta->binlog_config().is_enable(); }
+ bool enable_binlog() const {
+ return config::enable_feature_binlog &&
_tablet_meta->binlog_config().is_enable();
+ }
+ bool enable_ccr_binlog() const {
+ return enable_binlog() &&
_tablet_meta->binlog_config().isCCRBinlogFormat();
+ }
+ bool enable_row_binlog() const {
+ return _tablet_meta->binlog_config().is_enable() &&
+ _tablet_meta->binlog_config().isRowBinlogFormat();
Review Comment:
`enable_row_binlog()` does not include the global
`config::enable_feature_binlog` gate that
`enable_binlog()`/`enable_ccr_binlog()` use. This means row binlog behavior can
be activated even when the binlog feature is globally disabled, which is
inconsistent with the other binlog modes. Consider implementing it as `return
enable_binlog() && ...isRowBinlogFormat()` to honor the global flag
consistently.
```suggestion
return enable_binlog() &&
_tablet_meta->binlog_config().isRowBinlogFormat();
```
##########
fe/fe-core/src/main/java/org/apache/doris/common/proc/TabletsProcDir.java:
##########
@@ -150,6 +149,8 @@ public List<List<Comparable>> fetchComparableResult(long
version, long backendId
tabletInfo.add(FeConstants.null_string); // meta url
tabletInfo.add(FeConstants.null_string); // compaction
status
tabletInfo.add(-1); // cooldown replica id
+ tabletInfo.add(-1L); // binlog data size
+ tabletInfo.add(-1L); // binlog file num
tabletInfo.add(""); // cooldown meta id
if (Config.isCloudMode()) {
Review Comment:
The placeholder row added when a tablet has no replicas no longer matches
the TITLE_NAMES column order. TITLE_NAMES puts `CooldownMetaId` before
`BinlogSize`/`BinlogFileNum`, but the empty-replica branch appends
BinlogSize/BinlogFileNum before adding the cooldown meta id, causing all
subsequent columns to be shifted/misreported. Reorder the appended values to
match TITLE_NAMES (CooldownReplicaId, CooldownMetaId, BinlogSize,
BinlogFileNum, ...).
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/TabletStatMgr.java:
##########
@@ -373,17 +386,14 @@ private void updateTabletStat(Long beId,
TTabletStatResult result) {
if (replica != null) {
replica.setDataSize(stat.getDataSize());
replica.setRemoteDataSize(stat.getRemoteDataSize());
-
replica.setLocalInvertedIndexSize(stat.getLocalIndexSize());
-
replica.setLocalSegmentSize(stat.getLocalSegmentSize());
-
replica.setRemoteInvertedIndexSize(stat.getRemoteIndexSize());
-
replica.setRemoteSegmentSize(stat.getRemoteSegmentSize());
replica.setRowCount(stat.getRowCount());
replica.setTotalVersionCount(stat.getTotalVersionCount());
replica.setVisibleVersionCount(stat.isSetVisibleVersionCount() ?
stat.getVisibleVersionCount()
: stat.getTotalVersionCount());
- // Older version BE doesn't set visible version. Set
it to max for compatibility.
-
replica.setLastReportVersion(stat.isSetVisibleVersion() ?
stat.getVisibleVersion()
- : Long.MAX_VALUE);
+ if (stat.isSetBinlogSize()) {
+ replica.setBinlogSize(stat.getBinlogSize());
+ replica.setBinlogFileNum(stat.getBinlogFileNum());
+ }
Review Comment:
TabletStatMgr.updateTabletStat() no longer updates replica fields like
local/remote index/segment sizes and `lastReportVersion`. These values are used
elsewhere (e.g. tabletReported logic in TabletStatMgr itself, and SHOW
DATA/local size accounting), and there is no other non-cloud update path that
sets them. Please restore the missing assignments (and keep backward
compatibility for older BE fields as before), while still conditionally setting
binlog fields when present.
--
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]