Skip to content

[improve](cloud) Skip non-MOW tablets for get_topn_tablet_delete_bitmap_score#65964

Open
mymeiyi wants to merge 2 commits into
apache:masterfrom
mymeiyi:fix-get_topn_tablet_delete_bitmap_score
Open

[improve](cloud) Skip non-MOW tablets for get_topn_tablet_delete_bitmap_score#65964
mymeiyi wants to merge 2 commits into
apache:masterfrom
mymeiyi:fix-get_topn_tablet_delete_bitmap_score

Conversation

@mymeiyi

@mymeiyi mymeiyi commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Problem Summary: CloudTabletMgr included non-MOW tablets when calculating the top-N delete bitmap score. Skip non-MOW tablets before reading and aggregating delete bitmap counts so the reported score only represents MOW tables.

### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary: CloudTabletMgr included non-MOW tablets when calculating the top-N delete bitmap score. Skip non-MOW tablets before reading and aggregating delete bitmap counts so the reported score only represents MOW tables.

### Release note

None

### Check List (For Author)

- Test: No need to test (one-line predicate change; per request, no test or build was run)
- Behavior changed: Yes (delete bitmap score metrics exclude non-MOW tablets)
- Does this need documentation: No
@mymeiyi
mymeiyi requested a review from gavinchou as a code owner July 23, 2026 11:09
Copilot AI review requested due to automatic review settings July 23, 2026 11:09
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines Apache Doris BE Cloud’s CloudTabletMgr::get_topn_tablet_delete_bitmap_score to ensure the reported delete-bitmap “top-N score” reflects only Merge-on-Write (MoW) tablets, by skipping non-MoW tablets before reading/aggregating delete bitmap counts.

Changes:

  • Skip tablets that are not enabled for unique-key MoW (enable_unique_key_merge_on_write()) when computing delete-bitmap counts.
  • Prevent non-MoW tablets from affecting total_delete_map_count, max score selection, and the top-N buffer.

Review Checkpoints (Skill Part 1.3)

  • Goal & correctness: The change directly enforces the stated goal (exclude non-MoW tablets) by adding an early filter before reading delete bitmap counts.
  • Change scope: Minimal and localized (single conditional change inside the traversal handler).
  • Concurrency / locks: No new shared-state or lock behavior introduced; the change only adds a short-circuit condition.
  • Lifecycle / SIOF: Not applicable (no new statics/globals or cross-TU init changes).
  • Config changes: None.
  • Compatibility / rolling upgrade: Not applicable (no format/protocol change).
  • Parallel code paths: No evidence in this diff of another equivalent scoring path that also needs the same filter.
  • Special conditional checks: Condition is straightforward and aligned with the PR intent (MoW-gating before delete-bitmap access).
  • Test coverage: No tests added/updated in this PR; the change targets an internal scoring/logging/diagnostic path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

gavinchou
gavinchou previously approved these changes Jul 23, 2026
@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Jul 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@mymeiyi

mymeiyi commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary

Request changes: the MoW predicate itself is the correct, minimal filter, but the resulting empty-eligible-set lifecycle is not propagated to the exported gauges; see the inline P2 finding.

Critical checkpoint conclusions

  • Goal and proof: Non-MoW tablets are removed before total/max aggregation, top-N selection, and the base-rowset phase. The existing metric regression covers only one positive MoW table, so it does not prove mixed membership or the positive-to-zero transition.
  • Scope and clarity: The one-line collector change is focused. Completing the behavior requires publishing zero from the cloud callback when a completed scan has no eligible tablets, plus focused coverage.
  • Concurrency and lifecycle: The tablet-map snapshot, weak-pointer pinning, immutable mode flag, and delete-bitmap shared lock introduce no new race or lock-order problem. Tablet drop/cache eviction is the concrete lifecycle that exposes the stale-gauge issue.
  • Configuration and compatibility: No configuration, protocol, storage-format, persistence, transaction, or FE/BE variable compatibility change is introduced.
  • Parallel paths: The shared-nothing implementation is structurally parallel, but its production bitmap persistence/mutation paths are MoW-gated; no concrete second local-path defect was substantiated.
  • Performance and observability: Filtering saves bitmap scan/sort/base-rowset work. Observability remains incorrect when zero samples are suppressed, which is the blocking finding.
  • Validation: Static review used the authoritative one-file diff and current head 89011a830c6c090edd87f7ce744d27b81dbdfe06. Current formatter, title, license/secret, and macOS BE-UT checks are green. Per the review-runner contract, no local build or test was run.
  • User focus: No additional user-provided focus was specified; the complete PR and metric lifecycle were reviewed.

Comment thread be/src/cloud/cloud_tablet_mgr.cpp
### What problem does this PR solve?

Issue Number: None

Related PR: apache#65964

Problem Summary: When a completed cloud tablet scan returned zero after all eligible MoW tablets were dropped or evicted, the callback skipped updating the delete bitmap score gauges and left stale positive values exposed. Always publish both completed-scan values so the gauges reset to zero when no eligible tablet remains.

### Release note

None

### Check List (For Author)

- Test: No need to test (straightforward metric assignment change; compilation and tests were not run per request)
- Behavior changed: Yes (delete bitmap score gauges now reset to zero when a completed scan has no positive score)
- Does this need documentation: No
@github-actions github-actions Bot removed the approved Indicates a PR has been approved by one committer. label Jul 24, 2026
@mymeiyi

mymeiyi commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary

No new blocking findings at head ed02449a5948abb6e06adb76fef56a42346f98b4. The MoW-only filter is correctly placed before the whole-tablet count, maximum, top-N insertion, and base-rowset follow-up. The new unconditional gauge assignments also resolve the stale positive-value defect raised in the existing inline thread by publishing zero after a completed empty/non-MoW-only scan.

Critical checkpoint conclusions

  • Goal and proof: Non-MoW CloudTablets can no longer affect the total/max diagnostic values or the top-N base-rowset phase. The existing metrics_p0/test_delete_bitmap_metrics.groovy test proves only a positive MoW sample; it does not cover mixed membership or the positive-to-zero transition.
  • Scope and clarity: The two changes are small and focused: one eligibility predicate and the necessary completed-scan gauge publication.
  • Concurrency and lifecycle: The periodic scanner snapshots weak tablet references, pins each live tablet before access, reads the immutable production MoW flag, and uses the existing tablet/delete-bitmap locks. Cache eviction, sync, publish, and compaction can make a sample eventual, but do not create unsafe access or a new lock-order issue. Both gauges now follow the latest completed scan, including the drop/eviction-to-zero lifecycle.
  • Configuration and compatibility: No configuration, RPC, storage-format, persistence, transaction, or FE/BE variable compatibility change is introduced.
  • Parallel paths and conditions: The shared-nothing implementation is structurally parallel but unchanged; no new patch-scoped defect was substantiated there. The early MoW condition is the correct and cheapest filter for this cloud path.
  • Performance and observability: Filtering avoids unnecessary bitmap scans, sorting, and base-rowset work for non-MoW tablets. Publishing both values unconditionally restores accurate zero-state observability.
  • Tests and validation: No test or expected-result file is changed. The focused positive-to-empty coverage request is already present in the existing line-584 thread, so it is not duplicated. Per the review-runner contract, no local build or test was run. At review time, formatter, CheckStyle, license, secret, and dependency checks were passing; macOS BE UT was still pending.
  • Data writes, persistence, and observability support: The patch is diagnostic-only and does not change transactionality, visibility, delete-bitmap persistence, crash recovery, or data-write atomicity. Existing identifiers and logs remain sufficient for this path.
  • User focus: No additional user-provided focus was specified; both changed files and their upstream/downstream metric lifecycle were reviewed.

@mymeiyi

mymeiyi commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 0.00% (0/4) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 58.04% (24556/42308)
Line Coverage 42.08% (244867/581865)
Region Coverage 38.00% (194632/512231)
Branch Coverage 39.09% (87604/224130)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (4/4) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 75.21% (31024/41252)
Line Coverage 59.73% (345254/578040)
Region Coverage 56.44% (290094/514031)
Branch Coverage 57.79% (129583/224222)

@mymeiyi

mymeiyi commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

run vault_p0

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 22866 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit ed02449a5948abb6e06adb76fef56a42346f98b4, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17724	3517	3484	3484
q2	2065	322	203	203
q3	10219	1225	711	711
q4	4678	309	226	226
q5	7744	732	483	483
q6	182	140	112	112
q7	715	675	484	484
q8	10255	1536	1563	1536
q9	4824	3110	3035	3035
q10	6747	1164	969	969
q11	495	323	305	305
q12	755	516	446	446
q13	17942	2335	1857	1857
q14	202	184	172	172
q15	q16	534	504	457	457
q17	998	945	991	945
q18	4832	3630	3330	3330
q19	2586	1257	1057	1057
q20	736	630	563	563
q21	5785	2438	2185	2185
q22	422	357	306	306
Total cold run time: 100440 ms
Total hot run time: 22866 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3952	3790	3778	3778
q2	245	248	188	188
q3	2687	2806	2450	2450
q4	1362	1331	1061	1061
q5	2656	2569	2524	2524
q6	255	155	103	103
q7	1311	1197	1087	1087
q8	1974	1716	1712	1712
q9	3697	3669	3639	3639
q10	2461	2396	2125	2125
q11	414	343	317	317
q12	572	552	399	399
q13	2265	2591	2046	2046
q14	233	223	208	208
q15	q16	505	524	451	451
q17	1244	1206	1212	1206
q18	4982	4773	4605	4605
q19	1142	1204	1176	1176
q20	1114	1092	951	951
q21	4303	3807	3798	3798
q22	512	414	416	414
Total cold run time: 37886 ms
Total hot run time: 34238 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 117159 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit ed02449a5948abb6e06adb76fef56a42346f98b4, data reload: false

query5	4340	556	438	438
query6	496	231	202	202
query7	4898	596	351	351
query8	375	188	165	165
query9	8814	3901	3920	3901
query10	484	353	290	290
query11	5500	1359	1240	1240
query12	161	105	92	92
query13	1254	598	442	442
query14	6061	2814	2631	2631
query14_1	2364	2329	2351	2329
query15	200	159	143	143
query16	1121	550	513	513
query17	1119	611	493	493
query18	2448	426	333	333
query19	219	198	149	149
query20	109	93	93	93
query21	233	147	133	133
query22	7428	7571	7475	7475
query23	9533	9138	8895	8895
query23_1	9175	9094	9013	9013
query24	7459	1398	997	997
query24_1	1010	1030	1004	1004
query25	566	453	368	368
query26	1319	367	224	224
query27	2532	550	374	374
query28	4362	2166	2138	2138
query29	1061	615	489	489
query30	328	237	192	192
query31	932	648	596	596
query32	127	66	64	64
query33	542	305	253	253
query34	1168	1128	667	667
query35	532	538	453	453
query36	1052	1052	1008	1008
query37	150	100	89	89
query38	1290	1047	993	993
query39	623	638	594	594
query39_1	626	610	588	588
query40	251	161	149	149
query41	83	72	61	61
query42	93	91	90	90
query43	295	304	247	247
query44	1348	782	800	782
query45	134	135	125	125
query46	1094	1129	699	699
query47	1427	1416	1283	1283
query48	422	402	309	309
query49	594	314	232	232
query50	1024	423	345	345
query51	11071	11157	11110	11110
query52	93	87	73	73
query53	256	288	196	196
query54	272	258	204	204
query55	75	71	68	68
query56	285	267	284	267
query57	884	865	840	840
query58	286	252	248	248
query59	1316	1368	1236	1236
query60	315	261	236	236
query61	169	172	144	144
query62	414	294	296	294
query63	245	195	195	195
query64	2714	877	743	743
query65	2080	2071	2073	2071
query66	1838	406	323	323
query67	16272	16202	15522	15522
query68	3401	1399	994	994
query69	413	305	260	260
query70	1148	1061	1024	1024
query71	392	339	317	317
query72	2961	2491	2243	2243
query73	806	736	475	475
query74	1701	1518	1432	1432
query75	1604	1488	1257	1257
query76	2323	976	739	739
query77	329	342	266	266
query78	6165	5693	5418	5418
query79	2679	1005	752	752
query80	1793	575	462	462
query81	524	250	231	231
query82	611	144	115	115
query83	367	329	301	301
query84	279	155	135	135
query85	938	587	506	506
query86	438	316	295	295
query87	1147	1092	1050	1050
query88	3767	2940	2899	2899
query89	419	318	282	282
query90	2004	187	183	183
query91	206	191	162	162
query92	62	61	55	55
query93	1706	1450	1003	1003
query94	736	368	331	331
query95	750	574	431	431
query96	1049	837	336	336
query97	1382	1335	1255	1255
query98	191	174	170	170
query99	620	554	507	507
Total cold run time: 209901 ms
Total hot run time: 117159 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 18.56 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit ed02449a5948abb6e06adb76fef56a42346f98b4, data reload: false

query1	0.00	0.00	0.01
query2	0.11	0.04	0.04
query3	0.25	0.13	0.12
query4	1.61	0.13	0.13
query5	0.19	0.18	0.17
query6	1.21	0.98	0.94
query7	0.05	0.01	0.00
query8	0.05	0.04	0.03
query9	0.32	0.26	0.26
query10	0.43	0.46	0.42
query11	0.19	0.12	0.12
query12	0.17	0.12	0.12
query13	0.37	0.37	0.38
query14	0.59	0.61	0.62
query15	0.48	0.44	0.45
query16	0.25	0.23	0.26
query17	0.97	0.91	0.90
query18	0.24	0.23	0.22
query19	1.47	1.49	1.52
query20	0.02	0.01	0.01
query21	15.44	0.19	0.14
query22	4.97	0.05	0.06
query23	16.10	0.33	0.13
query24	2.89	0.40	0.33
query25	0.12	0.05	0.04
query26	0.72	0.20	0.16
query27	0.03	0.03	0.04
query28	3.49	0.82	0.47
query29	12.50	4.34	3.39
query30	0.26	0.15	0.14
query31	2.76	0.50	0.22
query32	3.32	0.41	0.28
query33	1.61	1.67	1.68
query34	15.29	2.80	2.18
query35	2.15	2.07	2.10
query36	0.49	0.33	0.33
query37	0.07	0.06	0.05
query38	0.05	0.04	0.04
query39	0.04	0.02	0.03
query40	0.14	0.11	0.12
query41	0.08	0.04	0.03
query42	0.04	0.03	0.03
query43	0.05	0.03	0.03
Total cold run time: 91.58 s
Total hot run time: 18.56 s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants