Skip to content

[feature](fe) Add resource group affinity extension framework#65173

Open
deardeng wants to merge 3 commits into
apache:masterfrom
deardeng:resource-group-impl-master
Open

[feature](fe) Add resource group affinity extension framework#65173
deardeng wants to merge 3 commits into
apache:masterfrom
deardeng:resource-group-impl-master

Conversation

@deardeng

@deardeng deardeng commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Problem Summary: Add a public Resource Group affinity extension framework for FE query, load, and repair scheduling paths while keeping the default community implementation as no-op. The change introduces shared policy interfaces, no-op factories, session/config/thrift fields, FE local resource group propagation, and observability fields so downstream implementations can plug in real affinity behavior without changing Apache default scheduling semantics.

What problem does this PR solve?

Issue Number: None

Related PR: None

Check List (For Author)

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

@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 marked this pull request as draft July 2, 2026 13:18
@deardeng deardeng force-pushed the resource-group-impl-master branch 2 times, most recently from 10b4692 to 01868c3 Compare July 2, 2026 15:28
@deardeng

deardeng commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

run buildall

@deardeng

deardeng commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator 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.

Superseded by review 4622392041 after repairing inline anchors. The original inline comments from this review were deleted and resubmitted with explicit line/side anchors.

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

Automated review summary:

I found three issues that need changes before this should land. The main problems are that two newly exposed FE configs are not wired into the runtime paths they describe, and the prepared point-query fast path does not preserve the new query affinity semantics.

Critical checkpoint conclusions:

  • Goal/test proof: the no-op public framework is mostly scoped, but the extension/config contract is incomplete in query and repair paths. Unit tests cover basic no-op/session validation, but not the disabled config paths or prepared point-query reuse.
  • Scope/focus: the change is generally focused on FE resource-group affinity plumbing; no existing inline threads or user focus items needed duplicate suppression.
  • Concurrency/lifecycle: no new FE locking issue found in the reviewed heartbeat, ServiceLoader, and scheduler paths.
  • Config/compatibility: optional thrift fields are compatible, but resource_tag_location_check and enable_repair_src_replica_local_affinity currently do not control behavior.
  • Parallel paths: query scan, prepared point query, stream/mysql/group-commit load, repair scheduling, frontends metadata, audit, and metrics paths were reviewed. The point-query path needs special handling because it reuses a cached scan node and shuffles candidate backends.
  • Validation: static review plus git diff --check on the correct one-commit PR range. I did not run FE tests/build because this checkout is missing thirdparty/installed/bin/protoc, and fe/AGENTS.md requires stopping FE build setup in that case.

Subagent conclusions: optimizer-rewrite OR-1 and OR-2 were merged into M-1 and submitted as one inline comment. tests-session-config TS-1 became M-2 and TS-2 became M-3. No candidates were dismissed or duplicate-suppressed. Convergence round 2, after anchor repair, ended with both live subagents returning NO_NEW_VALUABLE_FINDINGS for this exact final comment set.

Comment thread fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java Outdated
Comment thread fe/fe-common/src/main/java/org/apache/doris/common/Config.java
Comment thread fe/fe-common/src/main/java/org/apache/doris/common/Config.java Outdated
@deardeng

deardeng commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator 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.

Requesting changes based on four affinity-framework gaps that are still live in the current head.

Critical checkpoint conclusions:

  • Goal/test: the PR adds the public Resource Group affinity extension surfaces, but the current code does not fully apply them across query/load scheduling paths. Unit tests cover no-op behavior, session validation, and two config gates, but not the affected cloud load and query scheduling cases below.
  • Scope/focus: the framework is mostly localized, but it touches several parallel FE scheduling paths; the remaining issues are exactly in those parallel paths.
  • Concurrency/lifecycle: no new FE lock or edit-log lifecycle issue found in this pass. Prepared short-circuit stale affinity was already covered by existing review context and is addressed in the current head.
  • Configuration/session propagation: the previously raised config gates are now wired in the current head. Remaining load-affinity session behavior is not propagated to cloud non-group stream/MySQL load placement.
  • Compatibility: new thrift fields are optional. I could not run generation/build validation here because .worktree_initialized, thirdparty/installed, and executable thirdparty/installed/bin/protoc are missing.
  • Parallel paths: issues remain between local vs cloud load paths, legacy vs Nereids scan assignment, and plan-time vs audit-time query affinity decisions.
  • Tests/observability: missing tests for effective downstream policies on cloud load, ordinary OLAP scan placement, and statement-level query-affinity audit consistency. The new audit fields currently compute a fresh decision instead of reporting the statement decision.
  • Transactions/persistence/data writes/performance: no storage, transaction, or persistence correctness issue found; the main performance concern is semantic scheduling behavior, not overhead.

User focus: no additional user-provided focus was supplied.

Subagent conclusions: tests-session-config proposed TSC-1, accepted as M-2. optimizer-rewrite proposed OR-1 and OR-2 during convergence, accepted as M-3 and M-4. M-1 was found by the main pass. Existing threads 3517152408, 3517152410, and 3517152404 were treated as already-known/stale context and not resubmitted. Convergence completed in round 3 with both optimizer-rewrite and tests-session-config returning NO_NEW_VALUABLE_FINDINGS for the same four-comment set.

Comment thread fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java Outdated
Comment thread fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java Outdated
Comment thread fe/fe-core/src/main/java/org/apache/doris/qe/AuditLogHelper.java Outdated
@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17755	4177	4114	4114
q2	2029	327	193	193
q3	10312	1470	827	827
q4	4758	478	345	345
q5	8120	965	584	584
q6	293	177	137	137
q7	839	836	643	643
q8	10586	1626	1751	1626
q9	5892	4415	4454	4415
q10	6826	1775	1577	1577
q11	528	359	323	323
q12	712	558	433	433
q13	18178	3371	2744	2744
q14	264	260	237	237
q15	q16	793	773	710	710
q17	992	955	1046	955
q18	7133	5783	5551	5551
q19	1186	1169	994	994
q20	754	683	546	546
q21	5471	2632	2538	2538
q22	437	369	295	295
Total cold run time: 103858 ms
Total hot run time: 29787 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4446	4411	4375	4375
q2	267	309	207	207
q3	4616	5008	4347	4347
q4	2067	2144	1363	1363
q5	4475	4298	4358	4298
q6	223	311	204	204
q7	2075	1896	1647	1647
q8	2572	2269	2211	2211
q9	8282	7998	7950	7950
q10	4750	4745	4292	4292
q11	581	414	382	382
q12	784	763	559	559
q13	3315	3559	2967	2967
q14	305	293	276	276
q15	q16	707	723	656	656
q17	1377	1504	1315	1315
q18	7927	7321	7219	7219
q19	1086	1133	1102	1102
q20	2213	2206	1942	1942
q21	5243	4514	4412	4412
q22	516	466	401	401
Total cold run time: 57827 ms
Total hot run time: 52125 ms

@hello-stephen

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

query5	4348	658	477	477
query6	472	227	217	217
query7	5053	613	338	338
query8	345	197	178	178
query9	8769	4034	4008	4008
query10	486	367	295	295
query11	5928	2370	2163	2163
query12	158	104	112	104
query13	1242	635	437	437
query14	6282	5286	4984	4984
query14_1	4326	4291	4268	4268
query15	219	210	183	183
query16	1038	483	450	450
query17	1128	756	593	593
query18	2675	495	345	345
query19	218	191	154	154
query20	112	113	108	108
query21	238	157	132	132
query22	13660	13579	13452	13452
query23	17422	16632	16257	16257
query23_1	16297	16249	16319	16249
query24	7512	1773	1313	1313
query24_1	1318	1330	1328	1328
query25	570	472	389	389
query26	1330	352	208	208
query27	2578	599	380	380
query28	4486	2050	2025	2025
query29	1084	647	510	510
query30	335	280	227	227
query31	1114	1099	975	975
query32	110	65	58	58
query33	536	321	264	264
query34	1189	1132	630	630
query35	775	784	652	652
query36	1460	1376	1245	1245
query37	157	104	98	98
query38	1874	1710	1662	1662
query39	934	912	906	906
query39_1	928	886	884	884
query40	242	161	135	135
query41	64	62	64	62
query42	93	91	94	91
query43	326	322	278	278
query44	1463	781	765	765
query45	209	188	195	188
query46	1159	1182	777	777
query47	2335	2337	2227	2227
query48	406	413	296	296
query49	574	431	314	314
query50	1038	421	328	328
query51	4446	4394	4402	4394
query52	87	84	77	77
query53	267	284	215	215
query54	282	235	210	210
query55	79	69	71	69
query56	290	292	285	285
query57	1431	1424	1310	1310
query58	281	261	265	261
query59	1596	1643	1444	1444
query60	300	266	261	261
query61	153	149	146	146
query62	709	638	590	590
query63	237	203	207	203
query64	2528	765	611	611
query65	4841	4805	4778	4778
query66	1774	513	381	381
query67	29670	29532	29461	29461
query68	3194	1506	939	939
query69	399	301	273	273
query70	1062	948	965	948
query71	346	348	309	309
query72	2902	2654	2321	2321
query73	854	752	446	446
query74	5125	4965	4722	4722
query75	2593	2568	2225	2225
query76	2375	1214	803	803
query77	329	379	272	272
query78	12565	12504	11959	11959
query79	1474	1160	762	762
query80	810	560	451	451
query81	497	327	281	281
query82	565	157	123	123
query83	375	321	298	298
query84	282	170	130	130
query85	977	631	524	524
query86	410	305	286	286
query87	1839	1828	1743	1743
query88	3750	2802	2791	2791
query89	452	408	371	371
query90	1910	202	195	195
query91	201	187	160	160
query92	65	60	56	56
query93	1571	1581	1011	1011
query94	622	363	299	299
query95	787	490	476	476
query96	1092	840	392	392
query97	2681	2726	2579	2579
query98	209	204	203	203
query99	1206	1152	1007	1007
Total cold run time: 259232 ms
Total hot run time: 173516 ms

@hello-stephen

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

query1	0.01	0.01	0.00
query2	0.10	0.05	0.04
query3	0.25	0.13	0.14
query4	1.62	0.14	0.13
query5	0.23	0.23	0.22
query6	1.22	1.11	1.02
query7	0.04	0.01	0.00
query8	0.06	0.04	0.03
query9	0.37	0.31	0.31
query10	0.56	0.53	0.54
query11	0.20	0.15	0.14
query12	0.19	0.15	0.15
query13	0.47	0.47	0.46
query14	1.04	1.00	1.00
query15	0.61	0.58	0.59
query16	0.34	0.34	0.33
query17	1.08	1.11	1.06
query18	0.24	0.21	0.21
query19	2.02	1.93	1.86
query20	0.01	0.01	0.01
query21	15.43	0.22	0.14
query22	4.82	0.05	0.05
query23	16.12	0.31	0.13
query24	2.96	0.46	0.29
query25	0.12	0.05	0.04
query26	0.73	0.21	0.16
query27	0.04	0.05	0.04
query28	3.52	0.91	0.52
query29	12.48	4.42	3.45
query30	0.28	0.15	0.15
query31	2.77	0.58	0.31
query32	3.23	0.60	0.50
query33	3.22	3.23	3.19
query34	15.67	4.22	3.51
query35	3.54	3.53	3.51
query36	0.54	0.43	0.43
query37	0.09	0.07	0.06
query38	0.05	0.05	0.04
query39	0.04	0.03	0.03
query40	0.18	0.17	0.17
query41	0.08	0.03	0.03
query42	0.05	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 96.66 s
Total hot run time: 25.02 s

@deardeng

deardeng commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator 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.

Static review against head a71cbb6. I found three correctness issues in the new affinity handling: skip_missing_version replica ordering can be weakened, group-commit backend caching bypasses the effective load-affinity decision, and the default load helper can return an unavailable backend when cloud callers pass unfiltered candidates.

Comment thread fe/fe-core/src/main/java/org/apache/doris/planner/OlapScanNode.java Outdated
Comment thread fe/fe-core/src/main/java/org/apache/doris/load/GroupCommitManager.java Outdated
@deardeng

deardeng commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator 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.

Static review found two issues that need changes before merge: forwarded SQL can resolve the requester local resource group from stale heartbeat cache, and the frontends() TVF regression expectations were not updated for the new column. I could not run FE/regression tests because thirdparty/installed/bin/protoc is missing in this checkout.

Comment thread fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java Outdated
@deardeng deardeng force-pushed the resource-group-impl-master branch from 0675b7e to c438e64 Compare July 3, 2026 08:49
@deardeng deardeng force-pushed the resource-group-impl-master branch from aba1f40 to 37abfb3 Compare July 3, 2026 14:53
@deardeng

deardeng commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator 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.

Automated review summary for PR 65173 at head 37abfb3b58969871e8caec809a1d9eab2a0ce6d1.

I reviewed the current patch, existing inline review threads, changed-file list, FE/Core AGENTS guidance, and the shared subagent ledger. I do not have additional non-duplicate inline comments to add in this pass. The one remaining scan-affinity concern found during review is already covered by the existing Coordinator.java:2518 inline thread, so I did not resubmit it.

Critical checkpoint conclusions:

  • Goal and scope: the PR adds a Resource Group affinity SPI and wires query/load/repair scheduling, FE local resource group propagation, audit/frontends observability, session/config/thrift fields, and default no-op behavior. Current head includes fixes for several existing comments around load-affinity gates, audit table schema, frontends() output, invalid compute-group laziness, forwarded local group, and group-commit affinity.
  • Size/focus: the change is broad but consistently scoped to FE resource-group affinity and related observability/forwarding surfaces.
  • Concurrency/lifecycle: no new lock-order or heavy-under-lock issue found. The local FE resource group remains transient on Frontend, with heartbeat refresh plus per-request forwarding to avoid stale requester context.
  • Configuration/compatibility: new thrift fields are optional; session variables are marked for forwarding and validated; the repair-source and resource-tag gates are wired in current head.
  • Parallel paths: stream load, MySQL load, group commit, sink explain, scan planning, point-query lazy evaluation, and coordinator assignment paths were checked. Remaining scan-assignment ordering behavior is duplicate of an existing review thread.
  • Tests/results: new FE unit tests and the frontends() regression update cover the changed surfaces that were practical to inspect statically. I ran bash -n bin/start_fe.sh. Maven/regression tests were not run because this checkout lacks thirdparty/installed and thirdparty/installed/bin/protoc.
  • Observability: audit text/table fields, frontends() output, SHOW FRONTENDS proc output, and clone affinity metrics were checked for ordering/coverage issues.
  • Persistence/transaction/data writes: no edit-log, storage-format, or transaction atomicity issue found in the reviewed changes.

User focus points: no additional user-provided review focus was specified.

Subagent conclusions: optimizer-rewrite reported only OPT-DUP-001, which was merged as duplicate of the existing Coordinator.java:2518 thread; tests-session-config reported no candidates. Final convergence round 1 ended with both live subagents replying NO_NEW_VALUABLE_FINDINGS for the current ledger and empty proposed final comment set.

@deardeng

deardeng commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.39% (1896/2450)
Line Coverage 64.42% (34052/52862)
Region Coverage 64.85% (17529/27032)
Branch Coverage 54.00% (9390/17390)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 34.50% (168/487) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17942	4264	4511	4264
q2	2035	329	200	200
q3	10688	1507	877	877
q4	4796	485	351	351
q5	8235	866	579	579
q6	318	184	148	148
q7	865	870	626	626
q8	10389	1643	1735	1643
q9	5810	4483	4434	4434
q10	6855	1798	1514	1514
q11	526	359	316	316
q12	753	580	455	455
q13	18161	3987	2775	2775
q14	278	263	246	246
q15	q16	791	786	711	711
q17	964	915	1018	915
q18	7073	5746	5547	5547
q19	1157	1307	1126	1126
q20	808	661	552	552
q21	5652	2649	2535	2535
q22	439	369	307	307
Total cold run time: 104535 ms
Total hot run time: 30121 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4589	4502	4447	4447
q2	307	342	227	227
q3	4669	4999	4435	4435
q4	2171	2254	1397	1397
q5	4575	4450	5191	4450
q6	264	216	147	147
q7	2056	1838	1619	1619
q8	2656	2330	2286	2286
q9	8038	7958	7874	7874
q10	4821	4825	4266	4266
q11	667	454	437	437
q12	778	764	584	584
q13	3381	3704	2984	2984
q14	300	328	273	273
q15	q16	719	779	667	667
q17	1434	1378	1340	1340
q18	8206	7401	6901	6901
q19	1145	1114	1114	1114
q20	2259	2216	1987	1987
q21	5445	4835	4636	4636
q22	534	476	422	422
Total cold run time: 59014 ms
Total hot run time: 52493 ms

@hello-stephen

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

query5	4342	636	482	482
query6	465	231	197	197
query7	4850	617	338	338
query8	334	193	175	175
query9	8807	4071	4087	4071
query10	477	344	321	321
query11	5956	2343	2141	2141
query12	196	103	106	103
query13	1270	611	420	420
query14	6264	5324	4955	4955
query14_1	4300	4300	4295	4295
query15	216	199	183	183
query16	1026	469	442	442
query17	1126	735	575	575
query18	2492	466	341	341
query19	239	204	149	149
query20	114	110	106	106
query21	233	158	138	138
query22	13716	13733	13494	13494
query23	17343	16548	16236	16236
query23_1	16240	16352	16256	16256
query24	7659	1820	1314	1314
query24_1	1334	1325	1332	1325
query25	737	481	403	403
query26	1371	365	215	215
query27	2614	592	383	383
query28	4489	2013	2020	2013
query29	1083	639	503	503
query30	343	262	233	233
query31	1125	1109	997	997
query32	115	65	66	65
query33	537	329	265	265
query34	1199	1194	665	665
query35	761	804	681	681
query36	1391	1368	1236	1236
query37	163	112	93	93
query38	1939	1703	1676	1676
query39	941	916	902	902
query39_1	891	875	863	863
query40	263	167	146	146
query41	72	70	90	70
query42	103	97	103	97
query43	337	338	291	291
query44	1475	789	780	780
query45	213	190	191	190
query46	1108	1222	747	747
query47	2378	2303	2199	2199
query48	424	404	301	301
query49	605	445	326	326
query50	1107	452	357	357
query51	4589	4355	4311	4311
query52	92	89	77	77
query53	272	285	204	204
query54	303	270	275	270
query55	77	73	70	70
query56	332	312	299	299
query57	1416	1405	1305	1305
query58	348	266	266	266
query59	1641	1678	1465	1465
query60	315	281	265	265
query61	181	177	210	177
query62	695	655	586	586
query63	233	215	215	215
query64	2513	762	621	621
query65	4881	4830	4777	4777
query66	1812	502	388	388
query67	29756	29569	29377	29377
query68	3408	1583	915	915
query69	418	311	274	274
query70	1096	936	1004	936
query71	359	332	319	319
query72	3016	2630	2391	2391
query73	912	833	454	454
query74	5240	5026	4788	4788
query75	2746	2616	2253	2253
query76	2325	1238	826	826
query77	360	378	284	284
query78	12543	12594	12073	12073
query79	1490	1187	804	804
query80	1305	545	486	486
query81	582	324	274	274
query82	646	167	125	125
query83	369	322	304	304
query84	282	162	134	134
query85	1025	611	516	516
query86	515	292	285	285
query87	1861	1824	1758	1758
query88	3822	2846	2817	2817
query89	483	402	364	364
query90	1938	212	203	203
query91	207	193	168	168
query92	66	65	58	58
query93	1738	1590	1009	1009
query94	801	390	330	330
query95	868	497	582	497
query96	1073	812	363	363
query97	2699	2693	2552	2552
query98	214	205	200	200
query99	1192	1154	1046	1046
Total cold run time: 262426 ms
Total hot run time: 174754 ms

@hello-stephen

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

query1	0.00	0.00	0.01
query2	0.15	0.09	0.08
query3	0.40	0.25	0.25
query4	1.62	0.25	0.28
query5	0.33	0.32	0.31
query6	1.16	0.68	0.67
query7	0.04	0.00	0.00
query8	0.09	0.08	0.07
query9	0.51	0.39	0.39
query10	0.59	0.59	0.58
query11	0.32	0.19	0.18
query12	0.32	0.18	0.19
query13	0.53	0.54	0.53
query14	0.93	0.93	0.94
query15	0.67	0.60	0.61
query16	0.39	0.39	0.39
query17	1.03	1.04	1.00
query18	0.31	0.29	0.29
query19	1.90	1.76	1.80
query20	0.02	0.02	0.01
query21	15.44	0.37	0.32
query22	4.84	0.14	0.14
query23	15.81	0.51	0.31
query24	2.60	0.63	0.43
query25	0.15	0.10	0.10
query26	0.76	0.27	0.21
query27	0.10	0.10	0.10
query28	3.51	0.90	0.53
query29	12.46	4.44	3.54
query30	0.40	0.26	0.27
query31	2.78	0.63	0.34
query32	3.23	0.59	0.47
query33	2.97	2.93	2.96
query34	15.79	4.12	3.42
query35	3.33	3.32	3.26
query36	0.66	0.54	0.51
query37	0.12	0.09	0.09
query38	0.09	0.06	0.06
query39	0.09	0.06	0.06
query40	0.19	0.18	0.17
query41	0.13	0.09	0.08
query42	0.08	0.06	0.06
query43	0.07	0.07	0.07
Total cold run time: 96.91 s
Total hot run time: 25.93 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 72.93% (29052/39837)
Line Coverage 56.50% (313969/555713)
Region Coverage 53.15% (262133/493160)
Branch Coverage 54.10% (114872/212328)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 36.76% (179/487) 🎉
Increment coverage report
Complete coverage report

@deardeng deardeng force-pushed the resource-group-impl-master branch 2 times, most recently from 961cd32 to 7a141ca Compare July 9, 2026 11:19
deardeng added 2 commits July 9, 2026 19:25
Issue Number: None

Related PR: None

Problem Summary: Add a public Resource Group affinity extension framework for FE query, load, and repair scheduling paths while keeping the default community implementation as no-op. The change introduces shared policy interfaces, no-op factories, session/config/thrift fields, FE local resource group propagation, and observability fields so downstream implementations can plug in real affinity behavior without changing Apache default scheduling semantics. The audit table schema and AuditLoader buffer now also include the new affinity audit fields so internal.__internal_schema.audit_log stays consistent with the text audit event. EXPLAIN INSERT and group commit load backend selection now use the same load-affinity enable gate as the real load scheduling paths, so disabled load affinity does not call downstream load decision hooks. Forwarded group commit requests only deserialize affinity decisions when the optional affinity fields are present. Scan range planning preserves the invalid-compute-group short-circuit before checking backend membership.

Add a no-op Resource Group affinity extension framework and related compatibility fields.

- Test: Unit Test / Regression test not run
    - mvn checkstyle:check -pl fe-core
    - mvn test -pl fe-core -am -Dtest=ResourceGroupAffinityNoOpPolicyTest,SessionVariableAffinityTest,OlapScanNodeAffinityConfigTest,TabletSchedCtxTest#testRepairSrcAffinityConfigGate -DfailIfNoTests=false
    - mvn -Dmaven.build.cache.enabled=false test -pl fe-core -am -Dtest=InternalSchemaInitializerTest,AuditLoaderTest -DfailIfNoTests=false
    - mvn -Dmaven.build.cache.enabled=false test -pl fe-core -am -Dtest=OlapTableSinkAffinityExplainTest -DfailIfNoTests=false
    - mvn -Dmaven.build.cache.enabled=false test -pl fe-core -am -Dtest=OlapScanNodeAffinityConfigTest,GroupCommitManagerAffinityTest,MasterOpExecutorAffinityTest,FrontendServiceImplAffinityTest,OlapTableSinkAffinityExplainTest -DfailIfNoTests=false
    - git diff --check
    - Regression test not run: only updated frontends() TVF assertion/projection for the new column and no local Doris cluster was started.
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: The OSS extension points for optional backend selection were named after resource group affinity, which exposed enterprise-specific semantics in public FE interfaces. This refactors the OSS boundary to generic backend selection concepts: SelectionHint, Mode, BackendSelectionPolicy, generic session, audit, thrift field names, and generic repair, load, and query selection hooks. The default OSS implementation remains no-op and existing non-cloud and cloud behavior is preserved.

### Release note

None

### Check List (For Author)

- Test:

    - Unit Test: ./run-fe-ut.sh --run org.apache.doris.resource.BackendSelectionNoOpPolicyTest,org.apache.doris.qe.SessionVariableBackendSelectionTest,org.apache.doris.qe.MasterOpExecutorBackendSelectionTest,org.apache.doris.service.FrontendServiceImplBackendSelectionTest,org.apache.doris.load.GroupCommitManagerBackendSelectionTest,org.apache.doris.planner.OlapScanNodeBackendSelectionConfigTest,org.apache.doris.planner.OlapTableSinkBackendSelectionExplainTest,org.apache.doris.plugin.audit.AuditLoaderTest,org.apache.doris.qe.PointQueryExecutorTest,org.apache.doris.qe.AuditLogHelperTest,org.apache.doris.load.loadv2.MysqlLoadManagerTest,org.apache.doris.httpv2.rest.LoadActionTest,org.apache.doris.clone.TabletSchedCtxTest,org.apache.doris.qe.CoordinatorTest

    - Manual test: mvn checkstyle:check -pl fe-core; ./build.sh --fe; git diff --check

- Behavior changed: No

- Does this need documentation: No
@deardeng deardeng force-pushed the resource-group-impl-master branch from 7a141ca to 830bb78 Compare July 9, 2026 11:32
@deardeng deardeng marked this pull request as ready for review July 9, 2026 11:35
@deardeng

deardeng commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.39% (1896/2450)
Line Coverage 64.46% (34075/52862)
Region Coverage 64.85% (17531/27032)
Branch Coverage 54.06% (9401/17390)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.87% (30001/40072)
Line Coverage 58.91% (329045/558533)
Region Coverage 55.73% (276316/495819)
Branch Coverage 56.94% (121496/213362)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 34.04% (194/570) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17618	4121	4221	4121
q2	2041	336	210	210
q3	10925	1449	817	817
q4	4733	475	344	344
q5	8344	875	609	609
q6	328	183	142	142
q7	844	836	621	621
q8	10444	1588	1548	1548
q9	5804	4422	4360	4360
q10	6766	1839	1510	1510
q11	504	354	322	322
q12	732	551	439	439
q13	18101	3394	2758	2758
q14	270	266	252	252
q15	q16	785	778	716	716
q17	1006	979	980	979
q18	7253	5883	5572	5572
q19	1181	1217	1075	1075
q20	748	658	549	549
q21	5705	2563	2500	2500
q22	435	368	300	300
Total cold run time: 104567 ms
Total hot run time: 29744 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4527	4389	4411	4389
q2	278	341	225	225
q3	4676	4917	4451	4451
q4	2226	2301	1455	1455
q5	4575	4440	4901	4440
q6	252	216	158	158
q7	2055	1819	1640	1640
q8	2569	2373	2314	2314
q9	7994	7971	7855	7855
q10	4754	5006	4360	4360
q11	634	479	430	430
q12	770	768	564	564
q13	3319	3623	2979	2979
q14	305	319	288	288
q15	q16	764	782	647	647
q17	1497	1366	1393	1366
q18	8338	7227	6856	6856
q19	1104	1078	1049	1049
q20	2218	2242	1959	1959
q21	5438	4782	4645	4645
q22	534	473	437	437
Total cold run time: 58827 ms
Total hot run time: 52507 ms

@hello-stephen

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

query5	4316	641	487	487
query6	467	214	197	197
query7	4896	611	314	314
query8	327	195	178	178
query9	8779	4076	4075	4075
query10	472	359	303	303
query11	5928	2360	2149	2149
query12	160	106	100	100
query13	1250	647	457	457
query14	6299	5324	4998	4998
query14_1	4310	4302	4238	4238
query15	220	195	193	193
query16	1049	478	455	455
query17	1116	703	553	553
query18	2518	464	346	346
query19	197	181	141	141
query20	109	107	103	103
query21	232	154	134	134
query22	13628	13593	13375	13375
query23	17443	16479	16161	16161
query23_1	16161	16265	16230	16230
query24	7692	1785	1299	1299
query24_1	1322	1300	1284	1284
query25	535	443	396	396
query26	1334	333	209	209
query27	2642	598	367	367
query28	4486	2042	2024	2024
query29	1057	646	510	510
query30	343	271	227	227
query31	1123	1092	987	987
query32	107	65	73	65
query33	536	321	270	270
query34	1257	1125	665	665
query35	776	784	685	685
query36	1463	1407	1204	1204
query37	171	108	97	97
query38	1881	1712	1656	1656
query39	927	938	891	891
query39_1	875	876	873	873
query40	251	163	158	158
query41	104	61	61	61
query42	94	92	91	91
query43	324	334	288	288
query44	1428	787	770	770
query45	198	185	182	182
query46	1082	1201	726	726
query47	2371	2328	2213	2213
query48	392	414	287	287
query49	581	419	311	311
query50	1081	417	326	326
query51	10654	10884	10732	10732
query52	85	96	73	73
query53	244	272	199	199
query54	318	231	225	225
query55	78	69	67	67
query56	282	300	280	280
query57	1431	1393	1312	1312
query58	275	254	273	254
query59	1603	1668	1427	1427
query60	328	262	252	252
query61	158	150	148	148
query62	699	651	575	575
query63	249	210	210	210
query64	2836	1054	892	892
query65	4845	4747	4826	4747
query66	1868	502	397	397
query67	29471	29437	29333	29333
query68	3169	1546	1046	1046
query69	443	328	284	284
query70	1070	989	1039	989
query71	364	317	313	313
query72	3102	2712	2436	2436
query73	846	795	465	465
query74	5161	4931	4739	4739
query75	2600	2606	2225	2225
query76	2364	1181	798	798
query77	364	385	285	285
query78	12176	12291	11798	11798
query79	1378	1166	772	772
query80	738	556	460	460
query81	491	318	277	277
query82	674	156	122	122
query83	388	334	298	298
query84	282	154	129	129
query85	990	601	514	514
query86	417	299	283	283
query87	1828	1817	1764	1764
query88	3756	2854	2804	2804
query89	465	409	356	356
query90	1774	202	202	202
query91	201	186	165	165
query92	60	60	55	55
query93	1567	1561	938	938
query94	611	365	327	327
query95	778	490	555	490
query96	1040	874	369	369
query97	2692	2718	2564	2564
query98	213	203	207	203
query99	1143	1178	1035	1035
Total cold run time: 265285 ms
Total hot run time: 180287 ms

@hello-stephen

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

query1	0.00	0.00	0.00
query2	0.15	0.12	0.08
query3	0.41	0.24	0.24
query4	1.62	0.24	0.25
query5	0.33	0.32	0.33
query6	1.17	0.68	0.67
query7	0.05	0.01	0.01
query8	0.09	0.08	0.07
query9	0.53	0.40	0.39
query10	0.61	0.60	0.61
query11	0.32	0.19	0.19
query12	0.32	0.19	0.19
query13	0.53	0.55	0.53
query14	0.93	0.92	0.93
query15	0.70	0.60	0.59
query16	0.40	0.39	0.40
query17	1.06	1.04	1.03
query18	0.31	0.30	0.29
query19	1.95	1.81	1.81
query20	0.02	0.02	0.01
query21	15.46	0.37	0.31
query22	4.92	0.15	0.13
query23	15.82	0.50	0.30
query24	2.42	0.61	0.45
query25	0.16	0.11	0.10
query26	0.78	0.27	0.22
query27	0.11	0.10	0.09
query28	3.52	0.94	0.52
query29	12.53	4.21	3.30
query30	0.37	0.27	0.26
query31	2.77	0.63	0.34
query32	3.23	0.60	0.48
query33	3.01	3.00	3.00
query34	15.78	4.13	3.40
query35	3.33	3.26	3.31
query36	0.68	0.54	0.51
query37	0.12	0.09	0.09
query38	0.09	0.07	0.06
query39	0.08	0.06	0.06
query40	0.21	0.17	0.17
query41	0.14	0.09	0.07
query42	0.16	0.06	0.06
query43	0.08	0.06	0.07
Total cold run time: 97.27 s
Total hot run time: 25.81 s

Issue Number: None

Related PR: None

Problem Summary: Fix five issues found in review of the backend selection
extension framework:

1. Restore the documented "random-be" redirect-policy wire value that the
   naming refactor accidentally changed to "default-be", which broke
   clients (including the built-in AuditStreamLoader) sending the
   documented header value.
2. Remove the "require" option from backend_selection_mode and the REQUIRE
   enum value. The SPI only lets implementations reorder candidates (never
   drop them) and callers keep applying their own load balancing, so a
   hard constraint cannot be honored; setting it now fails loudly instead
   of being silently ignored.
3. Keep the throwing protocol for forwarded group-commit backend selection
   errors unless the follower signals it understands statusCode/errMessage
   via the new optional supportsSelectionErrorResult thrift field. An old
   follower never reads those fields and would treat the unset
   groupCommitLoadBeId as backend 0 during rolling upgrades.
4. Bound the group-commit backend cache with a Guava cache
   (maximumSize + expireAfterAccess). Cache keys embed the user-supplied
   preference key, so the previous unbounded map could grow without limit
   under user-controlled session values.
5. Record the statement-level load selection hint on ConnectContext at the
   real scheduling sites (coordinator load path, group commit, forwarded
   group commit) and let the audit log prefer it over the scan-side query
   decision, so load statements no longer audit an empty or wrong hint.

- Test:
    - mvn -Dmaven.build.cache.enabled=false test -pl fe-core -am
      -Dtest=LoadActionTest,SessionVariableBackendSelectionTest,
      BackendSelectionNoOpPolicyTest,MasterOpExecutorBackendSelectionTest,
      FrontendServiceImplBackendSelectionTest,
      GroupCommitManagerBackendSelectionTest,AuditLogHelperTest,
      CoordinatorTest -DfailIfNoTests=false
      (Tests run: 59, Failures: 0, Errors: 0)
    - mvn checkstyle:check -pl fe-core
    - git diff --check
- Behavior changed: Yes, backend_selection_mode no longer accepts
  "require"; redirect-policy "random-be" works again as documented.
- Does this need documentation: No
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.

2 participants