Skip to content

[improvement](fe) Release cloud tablet scheduling indexes after balance - #66451

Open
deardeng wants to merge 2 commits into
apache:masterfrom
deardeng:improve-cloud-rebalance-release-scheduling-indexes
Open

[improvement](fe) Release cloud tablet scheduling indexes after balance#66451
deardeng wants to merge 2 commits into
apache:masterfrom
deardeng:improve-cloud-rebalance-release-scheduling-indexes

Conversation

@deardeng

@deardeng deardeng commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Related PR: #66378, #66389

Problem Summary: Cloud tablet route rebuilding retains the current and future table-level and partition-level scheduling indexes for the entire sleep interval after each balancing round, although later status checks and external readers only need the global indexes. At 4 million tablets across 4 clusters, a single-threaded JDK 17 path-level model estimates that releasing these four nested graphs reduces approximate post-full-GC retained route-index heap from 4.66 GiB to 1.35 GiB, a 3.31 GiB or 70.96% reduction. Cumulative route-index construction allocation remains 7.36 GiB, so this change reduces between-round retention rather than allocation volume or in-round peak memory. Replace the four top-level maps in a finally block after balancing so all exit paths release the old graphs without an O(N) clear traversal, while preserving current and future global routes. The next route-statistics pass rebuilds the scheduling indexes before they are used again. These numbers are model estimates, not production RSS measurements.

Release note

None

Check List (For Author)

  • Test: Unit Test
    • ./run-fe-ut.sh --run org.apache.doris.cloud.catalog.CloudTabletRebalancerTest (16 tests passed)
    • mvn checkstyle:check -pl fe-core (0 violations)
  • Behavior changed: No
  • Does this need documentation: No

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

### What problem does this PR solve?

Issue Number: None

Related PR: apache#66378, apache#66389

Problem Summary: Cloud tablet route rebuilding retains the current and future table-level and partition-level scheduling indexes for the entire sleep interval after each balancing round, although later status checks and external readers only need the global indexes. At 4 million tablets across 4 clusters, a single-threaded JDK 17 path-level model estimates that releasing these four nested graphs reduces approximate post-full-GC retained route-index heap from 4.66 GiB to 1.35 GiB, a 3.31 GiB or 70.96% reduction. Cumulative route-index construction allocation remains 7.36 GiB, so this change reduces between-round retention rather than allocation volume or in-round peak memory. Replace the four top-level maps in a finally block after balancing so all exit paths release the old graphs without an O(N) clear traversal, while preserving current and future global routes. The next route-statistics pass rebuilds the scheduling indexes before they are used again. These numbers are model estimates, not production RSS measurements.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.cloud.catalog.CloudTabletRebalancerTest (16 tests passed)
    - mvn checkstyle:check -pl fe-core (0 violations)
- Behavior changed: No
- Does this need documentation: No
@deardeng
deardeng requested a review from gavinchou as a code owner August 4, 2026 15:04
@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?

@deardeng

deardeng commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@deardeng

deardeng commented Aug 4, 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 opinion: Request changes.

One material lifecycle gap remains: the new cleanup fence covers every exit from performBalancing(), but not smooth-upgrade migration failures after route indexes have already been rebuilt. The inline comment gives the concrete failure path and the recommended wider fence.

Critical checkpoint conclusions:

  • Task goal and focus: replacing the four detailed current/future table/partition maps is an O(1) way to reduce between-round retained heap, and the normal balancing path accomplishes that goal. The accepted exception path makes the stated all-exit-path result incomplete. There was no additional user-provided focus.
  • Scope and parallel paths: the production change is small and focused; all four detailed current/future maps are released together, while current/future global, secondary, and colocate maps needed by later readers remain intact.
  • Concurrency and lifecycle: the daemon thread owns detailed-map construction, balancing, rollback application, and release. Warmup executor/checker threads keep ID-only task state and do not retain or read the released graphs. Normal returns, active-phase early returns, and exceptions from performBalancing() are safe; the pre-try migration exception is not.
  • Configuration, compatibility, and FE/BE contracts: no configuration, persisted format, function symbol, RPC/thrift contract, or rolling-upgrade compatibility surface changes.
  • Conditions, transactions, and data writes: routing/edit-log behavior is otherwise unchanged; post-balance decommission checks use the preserved current global map. No new transaction or persistence operation is introduced.
  • Tests and results: the helper-level unit test proves map replacement, global-map identity, and direct next-pass reconstruction, and adjacent coverage exercises warmup rollback after rebuild. It does not execute the production try/finally or its migration exception path. This review was static-only and ran no tests; the author reports 16 tests passed, matching the 16 @Test annotations currently in the class, but that result was not independently rerun here.
  • Observability and performance: no additional metrics/logging are needed for this lifetime-only change. Top-level replacement avoids an O(N) clear and the numerical heap claim is explicitly identified as a model estimate. No other correctness or performance issue was substantiated.

Review convergence is complete for the frozen diff and comment set: the final normal and risk-focused reviewers found no additional valuable findings, every candidate was independently adjudicated, and existing-thread duplicate suppression found no prior inline discussion.

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17601	3917	3907	3907
q2	2010	357	219	219
q3	10277	1429	835	835
q4	4717	480	338	338
q5	7760	841	558	558
q6	234	167	136	136
q7	769	807	596	596
q8	10416	1630	1465	1465
q9	5823	4080	4084	4080
q10	6745	1657	1373	1373
q11	505	379	328	328
q12	729	611	466	466
q13	18117	3319	2835	2835
q14	262	259	245	245
q15	q16	742	742	664	664
q17	1013	970	988	970
q18	6616	5588	5572	5572
q19	1198	1250	1022	1022
q20	810	677	588	588
q21	5564	2577	2465	2465
q22	442	347	299	299
Total cold run time: 102350 ms
Total hot run time: 28961 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4231	4168	4163	4163
q2	270	333	207	207
q3	4551	5003	4336	4336
q4	2203	2294	1419	1419
q5	4242	4085	4129	4085
q6	224	175	126	126
q7	1702	1604	1694	1604
q8	2490	2081	2117	2081
q9	7302	7260	7178	7178
q10	4303	4292	3903	3903
q11	551	388	364	364
q12	705	747	518	518
q13	3259	3705	2981	2981
q14	293	306	278	278
q15	q16	688	753	688	688
q17	1304	1309	1269	1269
q18	12176	11157	11808	11157
q19	1163	1148	1114	1114
q20	2248	2253	1935	1935
q21	5782	4998	4693	4693
q22	538	463	444	444
Total cold run time: 60225 ms
Total hot run time: 54543 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 166387 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 a553e2038bc4588fb12fef5b48bc98469e38cdd6, data reload: false

query5	4310	591	464	464
query6	481	229	210	210
query7	4905	547	330	330
query8	327	167	158	158
query9	8749	4014	4002	4002
query10	499	355	309	309
query11	5889	2192	2025	2025
query12	151	98	97	97
query13	1240	594	451	451
query14	6066	4237	3955	3955
query14_1	3779	3749	3737	3737
query15	195	192	175	175
query16	975	454	438	438
query17	916	714	547	547
query18	2454	474	338	338
query19	203	188	142	142
query20	103	103	102	102
query21	232	153	134	134
query22	13006	13022	12898	12898
query23	15716	14884	14564	14564
query23_1	14670	14625	14558	14558
query24	7475	1723	1244	1244
query24_1	1241	1243	1242	1242
query25	560	469	414	414
query26	1324	369	212	212
query27	2556	600	404	404
query28	4531	2100	2056	2056
query29	1069	634	498	498
query30	343	272	231	231
query31	1181	1140	1056	1056
query32	111	64	65	64
query33	537	335	255	255
query34	1205	1144	653	653
query35	728	774	640	640
query36	789	784	700	700
query37	159	112	95	95
query38	1831	1762	1671	1671
query39	841	827	788	788
query39_1	803	790	788	788
query40	257	168	153	153
query41	71	70	67	67
query42	99	97	96	96
query43	318	327	280	280
query44	1419	796	790	790
query45	188	177	182	177
query46	1062	1162	691	691
query47	1507	1536	1475	1475
query48	416	436	313	313
query49	618	431	319	319
query50	1109	437	353	353
query51	10238	10293	10218	10218
query52	91	95	78	78
query53	270	268	214	214
query54	294	257	235	235
query55	77	79	69	69
query56	326	321	332	321
query57	1021	1001	913	913
query58	299	277	277	277
query59	1582	1568	1341	1341
query60	322	286	271	271
query61	175	177	189	177
query62	396	317	265	265
query63	228	197	202	197
query64	2821	1053	837	837
query65	3810	3803	3778	3778
query66	1836	469	358	358
query67	28498	28116	27928	27928
query68	3298	1501	964	964
query69	407	297	302	297
query70	883	786	770	770
query71	370	324	309	309
query72	2998	2587	2320	2320
query73	810	794	443	443
query74	4631	4473	4289	4289
query75	2377	2340	1986	1986
query76	2322	1132	744	744
query77	343	371	279	279
query78	11257	11045	10712	10712
query79	1425	1157	740	740
query80	1257	562	475	475
query81	532	325	282	282
query82	622	173	135	135
query83	383	336	303	303
query84	332	154	130	130
query85	967	618	537	537
query86	406	233	206	206
query87	1999	1983	1821	1821
query88	3764	2849	2874	2849
query89	389	312	280	280
query90	1881	211	200	200
query91	205	197	164	164
query92	61	65	54	54
query93	1764	1650	979	979
query94	717	374	319	319
query95	767	508	578	508
query96	1045	794	336	336
query97	2461	2430	2340	2340
query98	198	190	186	186
query99	734	725	602	602
Total cold run time: 253017 ms
Total hot run time: 166387 ms

@hello-stephen

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

query1	0.01	0.00	0.01
query2	0.09	0.05	0.05
query3	0.25	0.14	0.14
query4	1.60	0.14	0.14
query5	0.24	0.23	0.22
query6	1.17	0.85	0.85
query7	0.04	0.01	0.01
query8	0.06	0.04	0.03
query9	0.39	0.30	0.34
query10	0.55	0.55	0.54
query11	0.18	0.13	0.13
query12	0.18	0.14	0.13
query13	0.47	0.47	0.47
query14	1.00	1.00	1.01
query15	0.61	0.59	0.59
query16	0.31	0.33	0.32
query17	1.11	1.12	1.12
query18	0.21	0.20	0.20
query19	2.07	1.96	1.95
query20	0.02	0.01	0.01
query21	15.43	0.21	0.14
query22	4.82	0.06	0.05
query23	16.14	0.31	0.12
query24	2.97	0.43	0.33
query25	0.11	0.06	0.04
query26	0.73	0.21	0.16
query27	0.05	0.04	0.04
query28	3.49	0.80	0.36
query29	12.48	4.04	3.15
query30	0.28	0.14	0.15
query31	2.77	0.56	0.31
query32	3.21	0.58	0.48
query33	3.16	3.18	3.18
query34	15.44	3.95	3.32
query35	3.22	3.25	3.20
query36	0.56	0.48	0.43
query37	0.10	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.15	0.15
query41	0.08	0.04	0.03
query42	0.03	0.03	0.02
query43	0.04	0.04	0.03
Total cold run time: 95.93 s
Total hot run time: 24.01 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (7/7) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?

Issue Number: None

Related PR: apache#66451, apache#66378, apache#66389

Problem Summary: Cloud tablet route indexes are rebuilt before smooth-upgrade migration, but the scheduling-index cleanup fence previously covered only performBalancing(). If migration or the optional second route rebuild threw after the first rebuild, the daemon propagated the failure without replacing the four current/future table-level and partition-level indexes, retaining their tablet membership graphs until a later cycle. Move the existing try/finally boundary before the first statRouteInfo() call so route rebuild, smooth-upgrade migration, the optional second rebuild, and balancing all release the scheduling-only indexes on every exit path. Global route indexes and exception propagation remain unchanged.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run org.apache.doris.cloud.catalog.CloudTabletRebalancerTest#testRunAfterCatalogReadyReleasesSchedulingIndexesWhenMigrationFails
    - ./run-fe-ut.sh --run org.apache.doris.cloud.catalog.CloudTabletRebalancerTest (17 tests passed)
    - mvn checkstyle:check -pl fe-core (0 violations)
- Behavior changed: No
- Does this need documentation: No
@deardeng

deardeng commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@deardeng

deardeng commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: All Codex review accounts are usage-limited; earliest retry is 2026-08-08T03:32:00Z.
Workflow run: https://github.com/apache/doris/actions/runs/30972349416

Please trigger /review again after that time.

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 50.00% (6/12) 🎉
Increment coverage report
Complete coverage report

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants