mrhhsg commented on code in PR #68125: URL: https://github.com/apache/doris/pull/68125#discussion_r4227789754
########## be/src/storage/read_time_hidden_column.cpp: ########## @@ -0,0 +1,91 @@ +// 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 "storage/read_time_hidden_column.h" + +#include "common/logging.h" +#include "core/column/column.h" +#include "storage/tablet/tablet_schema.h" +#include "storage/utils.h" + +namespace doris { + +ReadTimeHiddenColumnType get_read_time_hidden_column_type(const TabletColumn& column) { + const auto& column_name = column.name(); + if (column_name == VERSION_COL) { + return ReadTimeHiddenColumnType::VERSION; + } + if (column_name == COMMIT_TSO_COL) { + return ReadTimeHiddenColumnType::COMMIT_TSO; + } + if (column_name == BINLOG_TSO_COL) { + return ReadTimeHiddenColumnType::BINLOG_TSO; + } + return ReadTimeHiddenColumnType::NONE; +} + +ReadTimeHiddenColumnType get_read_time_hidden_column_type(const TabletSchema& schema, + int32_t column_unique_id) { + const int32_t column_idx = schema.field_index(column_unique_id); + if (column_idx < 0) { + return ReadTimeHiddenColumnType::NONE; + } + return get_read_time_hidden_column_type(schema.column(column_idx)); +} + +std::optional<Field> get_read_time_hidden_column_value(ReadTimeHiddenColumnType column_type, + const Version& version, + const TsoRange& commit_tso, + bool read_row_binlog) { + if (version.first != version.second) { Review Comment: Fixed in 43c0956f364 for the DUP COMMIT_TSO case as well. You are right about the reachability: `CreateTableInfo.addRowBinlogHiddenColumns` adds `__DORIS_COMMIT_TSO_COL__` to the base index of a row-format binlog DUP table, and only the companion index gets `TABLET_ROLE_ROW_BINLOG` (`InternalCatalog.createOlapTable`), so the base tablet's `is_row_binlog_tablet()` is false and it takes the normal tidy link path. My earlier LMax argument only covered the companion tablet. Reproduced locally with ee478f4c01c: after cumulative compaction linked `[2-2],[3-3]` the 8 linked rows read `__DORIS_COMMIT_TSO_COL__ = 0` and `FOR VERSION AS OF 0` returned them. Change: `has_load_placeholder_hidden_column(schema)` (read_time_hidden_column.h) names both columns a load stores as a placeholder, VERSION and COMMIT_TSO, and `is_rowset_tidy` uses it instead of the VERSION-only check, so single-version rowsets of either schema are rewritten and rowsets already rewritten into a multi-version rowset still link. BINLOG_TSO is left out on purpose: it only exists on row-binlog tablets, whose quick-merge path never reaches `is_rowset_tidy`. MOW tables (which also get COMMIT_TSO) were already excluded from the tidy link path. Coverage: - `OrderedDataCompactionTest.test_commit_tso_col_singleton_rowset_not_linked`: DUP schema with COMMIT_TSO, two tidy single-version rowsets -> `handle_ordered_data_compaction()` is false; the same rowsets as `[2-3]`/`[4-5]` -> true with a linked `[2-5]` output (shared helper with the VERSION case). - `fault_injection_p0/test_ordered_compaction_hidden_commit_tso_column`: row-format binlog DUP table, four loads with distinct commit TSOs; the `.out` locks each row's load number (`CASE __DORIS_COMMIT_TSO_COL__ WHEN <tso_i> THEN i ... ELSE 0`) and the `FOR VERSION AS OF <tso of load 2>` snapshot after cumulative compaction of `[2-2],[3-3]` and `[4-4],[5-5]` (rewritten, `num_segment_rows == [8]` / `[5]`) and after base compaction `[0-1],[2-3],[4-5] -> [0-5]` (linked, `[8, 5]`). Without the fix the first step links (`[3, 5]`), the rows report load 0 and the snapshot leaks them. -- 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]
