Doris-Breakwater commented on issue #70771:
URL: https://github.com/apache/doris/issues/70771#issuecomment-7027312251

   Breakwater-GitHub-Analysis-Slot: slot_3ca617b5afe3
   
   The supplied metadata describes a compaction-selection defect supported by 
source inspection. Please open the proposed PR. The issue is currently open 
with no labels; suggested triage is **bug / BE storage compaction**, with cloud 
impact demonstrated by the reported caller path. This is a liveness problem; 
the evidence here does not establish data loss.
   
   I inspected the public `4.1.4` source (commit 
`ad35a140c7fd0b842f18c23300bac581f7d04326`) and compared the policy with 
`branch-4.1` at `1330a0785d1e2149d354dfc82040a6aec7077df3` and `master` at 
`f76acb9b830c9d08ab5297c70d2bd61416883ed5`. The relevant behavior persists in 
both branches. This is a read-only code analysis: I have not run the proposed 
BE tests or reproduced the cluster transition.
   
   **Verified code behavior**
   
   - In 
[`pick_input_rowsets`](https://github.com/apache/doris/blob/ad35a140c7fd0b842f18c23300bac581f7d04326/be/src/storage/compaction/cumulative_compaction_time_series_policy.cpp#L296),
 the level-1 pass starts at the first singleton or zero-segment rowset. With 
the supplied layout, it skips the five merged rowsets in the minimal example. 
Without a trailing load, the level-2 pass then stops immediately at the first 
stored level-0 rowset. With the aged empty `[22-22]` load, condition 3 instead 
returns that singleton before reaching level 2.
   - The [cloud 
caller](https://github.com/apache/doris/blob/ad35a140c7fd0b842f18c23300bac581f7d04326/be/src/cloud/cloud_cumulative_compaction.cpp#L539)
 rejects both an empty selection and one non-overlapping rowset with 
`CUMULATIVE_NO_SUITABLE_VERSION`. Thus, for the supplied stable metadata and 
thresholds, repeated attempts cannot consume the merged prefix. Additional 
loads can still permit level-1 compactions of the tail; “permanent” should be 
understood as failure to drain that blocked prefix, rather than proof that 
every future cumulative attempt must fail.
   - 
[`get_compaction_level`](https://github.com/apache/doris/blob/ad35a140c7fd0b842f18c23300bac581f7d04326/be/src/storage/compaction/cumulative_compaction_time_series_policy.cpp#L458)
 returns 0 below threshold 2. After raising the threshold, a merge whose first 
input still has stored level 0 would produce level 1. The [cloud 
cumulative-point 
rule](https://github.com/apache/doris/blob/ad35a140c7fd0b842f18c23300bac581f7d04326/be/src/cloud/cloud_cumulative_compaction_policy.cpp#L347)
 retains the point for a non-empty output below level 2. Fixing selection alone 
would therefore be incomplete.
   - The high cloud score is consistent with this failure: 
[`get_cloud_cumu_compaction_score`](https://github.com/apache/doris/blob/ad35a140c7fd0b842f18c23300bac581f7d04326/be/src/cloud/cloud_tablet.cpp#L925)
 returns approximate cumulative deltas, not the local-tablet policy score. A 
failed preparation records a no-suitable-version timestamp, and scheduling 
applies a temporary backoff. That explains repeated skips without requiring a 
permanently frozen scheduler.
   
   One correction to the scoring analysis: in the local-tablet 
`calc_cumulative_compaction_score`, stored level-0 metas are classified as 
level 0 and excluded from `checked_rs_metas` before its level-2 loop. Its 
level-0 `break` is therefore not the operative barrier for this layout. If 
legacy rowsets are normalized there, update the initial classification as well; 
changing only the `break` would not make scoring consistent with selection.
   
   **Suggested PR scope and validation**
   
   The proposed direction is appropriate: consistently treat a multi-version, 
positive-segment, stored level-0 rowset as an already merged input when level-2 
mode is enabled; apply the same interpretation to selection, local scoring, and 
output-level calculation. Keep true unmerged singletons and zero-segment 
rowsets distinct. Apply the existing lone-non-overlapping guard to conditions 2 
and 3 while allowing fallthrough to level-2 and empty-rowset handling. Preserve 
compaction of a singleton with overlapping segments.
   
   Please include regression coverage for:
   
   1. The supplied mixed legacy-0/explicit-1 prefix, both without a tail and 
with an aged empty or non-empty non-overlapping singleton. Assert the selected 
versions, not just the return count.
   2. Output level 2 and cumulative-point advancement for a non-empty level-2 
result, including the cloud rule. Preserve the existing empty-output behavior.
   3. The 24-hour level-1 eligibility boundary and the level-2 time trigger 
(`10 × time_series_compaction_time_threshold_seconds`), plus condition 2 with 
file-count threshold 1. A non-overlapping singleton has score 1, so the 
count-trigger case requires that boundary setting.
   4. True unmerged/empty rowsets, delete-version handling, and version 
continuity, so normalization cannot advance the cumulative point across 
unprocessed versions. Retain coverage of the fetched-rowset behavior that 
motivated the initial skip.
   
   **Remaining evidence**
   
   The metadata is sufficient to explain the selection failure, but the actual 
threshold-transition sequence remains unverified. Alongside the PR/test output, 
please attach the exact BE build revision, sanitized table properties/key 
model, and a before/after snapshot for one affected tablet: cumulative point, 
ordered rowset versions, stored levels, segment counts, sizes, creation times, 
overlap flags, and delete predicates. Include the full no-suitable-version 
message and compaction timestamps around the ALTER. In particular, confirm how 
the pre-change level-0 outputs remained at or above the cumulative point; the 
current snapshot establishes the blocked state but not its creation history. A 
query profile is not needed to validate this selection path.
   


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