matanper opened a new issue, #71033: URL: https://github.com/apache/doris/issues/71033
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/doris/issues?q=is%3Aissue) and found no similar issues. ### Version 4.1.4 (cloud mode, `enable_parallel_cumu_compaction = true`). master is the same: - `be/src/storage/compaction/cumulative_compaction_time_series_policy.cpp:381-388` (level-2 scan in `pick_input_rowsets`) and `:126-132` (the same scan in `calc_cumulative_compaction_score`); - `be/src/cloud/cloud_cumulative_compaction.cpp:770` checks the continuity of the *candidates* only, not of the picked inputs; - `cloud/src/meta-service/meta_service_job.cpp:1380` (`txn->remove(rs_start, rs_end)`) removes every rowset key in the job's input version range. ### Description With `time_series_compaction_level_threshold = 2`, the level-2 scan walks the candidates in version order and does: ```cpp if (rs_meta->compaction_level() == 0) break; if (rs_meta->compaction_level() == 1 && (now - rs_meta->creation_time()) <= level2_compaction_timeout) { continue; // skips this rowset but keeps collecting the ones after it } level1_rowsets.push_back(rowset); ``` A level-1 rowset younger than 24 h is skipped, but the scan goes on collecting later rowsets, so the pick can be `[4-5], [8-9]` with `[6-7]` between them. Level-2 rowsets (and anything that is not a young level-1 rowset) are collected too. With `enable_parallel_cumu_compaction = true`, a cumulative compaction whose output does not start at the cumulative point does not move the point. Level-2 outputs therefore stay above the point, interleaved with younger level-1 rowsets. We saw this layout on several tablets of one time-series table, all with cumulative point 2: | Rowset | compaction_level | Age | |---|---|---| | [2-3] | 1 | 12.3 h | | [4-5] | 2 | 10.6 h | | [6-7] | 1 | 10.5 h | | [8-9] | 2 | 9.8 h | | [10-10] … [13-13] | 1 | 7–10 h | Once `[4-5]` was older than `10 × time_series_compaction_time_threshold_seconds` (condition 5), the scan returned `{[4-5], [8-9]}`. The BE merged them and committed a job with input range `[4-9]` and 2 input rowsets. The meta-service's commit removes every rowset key in `[4, 9]`, so `[6-7]` would be deleted and recycled without ever being read: silent data loss. The tablet stats are adjusted only by the job's declared counts, so they keep the lost rows. `CloudCumulativeCompaction::pick_rowsets_to_compact` checks that the candidates are contiguous, but not the policy's picked inputs, so nothing on the BE stops the job. The score function has the same `continue`. It also iterates `all_rs_metas()` (an `unordered_map`), so its level-2 scan sees the rowsets in no particular order, and it drops level-0 rowsets from the list, so its `break` on level 0 never fires. ### Solution 1. In both level-2 scans, end the run at a young level-1 rowset once the run has started (young rowsets before the run can still be passed over), so the pick is always version-contiguous. Sort the score's rowsets by version and keep level-0 rowsets in its list, so it stops where the pick stops. 2. In `CloudCumulativeCompaction::pick_rowsets_to_compact`, check `check_version_continuity(_input_rowsets)` after the policy's pick, and skip the compaction with a warning if it fails. 3. Optionally, in the meta-service, reject a compaction commit whose input range holds more rowsets than the job declares, instead of removing the whole range. We have a patch for 1 and 2, with unit tests, and can open a PR. ### How to Reproduce? 1. Cloud mode, `enable_parallel_cumu_compaction = true`. 2. A table with `"compaction_policy" = "time_series"` and `"time_series_compaction_level_threshold" = "2"`. 3. Load large single-version rowsets (each above `time_series_compaction_goal_size_mbytes`) so that some are merged in pairs into level-2 rowsets above the cumulative point, while level-1 rowsets younger than 24 h sit between them. This happens naturally under a sustained bulk load. 4. About 10 × `time_series_compaction_time_threshold_seconds` after the oldest such level-2 rowset was written, the level-2 scan picks two level-2 rowsets with a young level-1 rowset between them. The commit removes the skipped rowset. A unit test that builds the layout above and calls `TimeSeriesCumulativeCompactionPolicy::pick_input_rowsets` shows the gap directly. ### Anything Else? We have only seen this with parallel cumulative compaction. Without it, every level-2 output moves the cumulative point past itself, so level-2 rowsets do not stay above the point. Even so, the `continue` makes contiguity depend on creation times being in version order, which nothing guarantees. ### Are you willing to submit PR? - [x] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- 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]
