dataroaring commented on PR #62058:
URL: https://github.com/apache/doris/pull/62058#issuecomment-4181586594

   ## Code Review: [Feature] add binlog meta module (row type)
   
   **+3025 / -443 across 95 files**
   
   This PR introduces row-level binlog support for OlapTable — a new 
`BinlogFormat.ROW` mode that stores row-level change data as a separate 
materialized index within the origin table. Below are the issues found during 
review.
   
   ---
   
   ### Critical Issues
   
   #### 1. `TabletStatMgr.updateTabletStat()` accidentally removes replica stat 
updates
   
   The diff shows that the following lines were **removed** from 
`updateTabletStat()`:
   ```java
   replica.setLocalInvertedIndexSize(stat.getLocalIndexSize());
   replica.setLocalSegmentSize(stat.getLocalSegmentSize());
   replica.setRemoteInvertedIndexSize(stat.getRemoteIndexSize());
   replica.setRemoteSegmentSize(stat.getRemoteSegmentSize());
   replica.setLastReportVersion(stat.isSetVisibleVersion() ? 
stat.getVisibleVersion() : Long.MAX_VALUE);
   ```
   
   Only `setBinlogSize()` / `setBinlogFileNum()` should have been **added**. 
The removal of `setLastReportVersion()` is particularly dangerous — it affects 
replica health checks and clone decisions. This looks like an accidental 
deletion during merge/rebase.
   
   #### 2. `enable_row_binlog()` missing `config::enable_feature_binlog` check 
(BE)
   
   ```cpp
   // tablet.h
   bool enable_row_binlog() const {
       return _tablet_meta->binlog_config().is_enable() &&
              _tablet_meta->binlog_config().isRowBinlogFormat();
   }
   ```
   
   Compare with `enable_binlog()` and `enable_ccr_binlog()` which both check 
`config::enable_feature_binlog` first. Row binlog would be active even when the 
global feature flag is disabled. Should be:
   ```cpp
   bool enable_row_binlog() const {
       return config::enable_feature_binlog &&
              _tablet_meta->binlog_config().is_enable() &&
              _tablet_meta->binlog_config().isRowBinlogFormat();
   }
   ```
   
   #### 3. `VerticalRowBinlogRowsetWriter` returns `NotSupported` for all 
column operations (BE)
   
   The factory creates `VerticalRowBinlogRowsetWriter` when `is_vertical && 
is_binlog_writer()`, but `add_columns()`, `flush_columns()`, and 
`final_flush()` all return `NotSupported`. This means **loads will fail on 
row-binlog-enabled tables when vertical writing is triggered**.
   
   ---
   
   ### Major Issues
   
   #### 4. `BinlogConfig.binlogFormat` null for legacy deserialized configs (FE)
   
   `binlogFormat` is a new `@SerializedName` field. Legacy serialized configs 
will have `binlogFormat = null`. While `isEnableForCCR()` handles null 
correctly (`null != ROW` → true), `toProperties()` does:
   ```java
   properties.put(PROPERTIES_BINLOG_FORMAT, String.valueOf(binlogFormat));
   ```
   `String.valueOf(null)` → `"null"`, which will cause 
`BinlogFormat.valueOf("null")` to throw `IllegalArgumentException` if these 
properties are parsed back.
   
   #### 5. `Maps.filterValues()` returns live view — thread safety risk (FE)
   
   `OlapTable.getIndexIdToMeta()` and `getIndexNameToId()` now return 
`Maps.filterValues()` live views. Concurrent modifications to `indexIdToMeta` 
while iterating (e.g., in `rebuildFullSchema()`) can cause 
`ConcurrentModificationException`.
   
   #### 6. `set_data_writer()` dynamic_pointer_cast failure silently nulls the 
writer (BE)
   
   ```cpp
   void GroupRowsetWriter::set_data_writer(const RowsetWriterSharedPtr& 
txn_rowset_writer) {
       _txn_rowset_writer = 
std::dynamic_pointer_cast<BaseBetaRowsetWriter>(txn_rowset_writer);
   }
   ```
   If the cast fails, `_txn_rowset_writer` becomes null silently. All 
delegation methods (`num_rows()`, `flush()`, etc.) then crash with null deref. 
Needs a `DCHECK(_txn_rowset_writer != nullptr)` after the cast.
   
   #### 7. `operator<<` for `std::vector<RowsetId>` may not exist (BE)
   
   In `pending_rowset_helper.cpp`, the `CHECK` macro logs `<< _rowset_ids` 
which is a `std::vector<RowsetId>`. Unless Doris has a project-wide 
`operator<<` for vectors, this is a **build break**.
   
   #### 8. `InternalCatalog` semantic mismatch: `getEnable()` vs 
`isEnableForCCR()` (FE)
   
   ```java
   if (dbBinlogConfig.getEnable() && !createTableBinlogConfig.isEnableForCCR() 
&& ...)
   ```
   If the DB has `binlog.format=ROW` with `enable=true`, `getEnable()` returns 
true but `isEnableForCCR()` for the table returns false (also ROW format). This 
incorrectly blocks creating ROW-format tables under ROW-format databases.
   
   ---
   
   ### Minor Issues
   
   | Issue | Severity | Location |
   |-------|----------|----------|
   | `Boolean.parseBoolean()` never throws — `need_historical_value` validation 
unreachable | Low | `PropertyAnalyzer.java` |
   | `GroupRowsetWriter` methods use `LOG(FATAL)` instead of returning 
`Status::NotSupported` — crashes BE on accidental invocation | Medium | 
`group_rowset_writer.h` |
   | `PendingRowsetGuard::drop()` resets to 1-element vector with default 
RowsetId instead of empty | Low | `pending_rowset_helper.cpp` |
   | `binlog_format()` getter returns `int32_t` for a `BinlogFormatPB` field 
(implicit enum-to-int narrowing) | Low | `binlog_config.h` |
   | `_need_before` field is set but never read (dead code) | Low | 
`rowset_writer_context.h` |
   | Resource leak window: if `_txn_rs_builder->init()` fails after 
`_row_binlog_rowset_builder->init()` succeeds, binlog rowset files may be 
orphaned | Medium | `rowset_builder.cpp` |
   
   ---
   
   ### Design Concerns
   
   - **`OlapTableWrapper` extends `OlapTable`**: This creates a fragile 
split-state where the wrapper's own `indexIdToMeta`, `fullSchema`, etc. can 
drift from the origin table. Any new method added to `OlapTable` that accesses 
internal state won't automatically delegate. An interface-based or composition 
pattern would be cleaner.
   
   - **Schema evolution is partially manual**: ADD/DROP COLUMN are handled but 
MODIFY COLUMN is explicitly blocked. Future schema change operations added to 
Doris could silently drift the row binlog schema if they're not also 
blocked/handled.
   
   ---
   
   ### Test Coverage
   
   - No regression tests (checkbox unchecked in PR)
   - No tests for `OlapTableWrapper` / `RowBinlogTableWrapper`
   - No test for `BinlogConfig` serialization round-trip with new fields 
(especially null `binlogFormat` legacy compat)
   - No test for backup/restore rejection when row binlog is enabled
   - FE UT increment coverage: **53.25%** (303/569 lines)


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