Skip to content

[feature](query) Support session level force_forward_all_queries - #66691

Open
yujun777 wants to merge 1 commit into
apache:masterfrom
yujun777:feat-cir-21346-force-forward-all-queries
Open

[feature](query) Support session level force_forward_all_queries#66691
yujun777 wants to merge 1 commit into
apache:masterfrom
yujun777:feat-cir-21346-force-forward-all-queries

Conversation

@yujun777

@yujun777 yujun777 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Problem Summary:

Some users query a freshness/health-check on a follower FE before every business request. When the follower is replaying a large journal, the freshness query result can lag and trigger business degradation. Config.force_forward_all_queries = true forces all queries to the master, but it is cluster-wide and too coarse when clients connect through a load balancer. The existing session variable forward_to_master does not participate in the ordinary SELECT forwarding decision.

This PR adds a session-level variable force_forward_all_queries. A query is forwarded to the master when either Config.force_forward_all_queries or the session variable is enabled, so only the freshness queries need to opt in.

Release note

Added a session variable force_forward_all_queries to force queries of the session to be forwarded to the master FE.

Check List (For Author)

  • Test:
    • Unit test: ForceForwardAllQueriesTest (4 scenarios: session/config on/off combinations, passed)
    • Full FE build with checkstyle passed
  • Behavior changed: Yes (new session variable, default off, no behavior change when disabled)
  • Does this need documentation: No

Add a session variable force_forward_all_queries so that a session can
force all its queries to be forwarded to the master FE, without enabling
the cluster-wide Config.force_forward_all_queries. A query is forwarded
when either the config or the session variable is enabled.

Key changes:
- Add session variable force_forward_all_queries (default false)
- Forward queries when Config.force_forward_all_queries or the session variable is enabled
- Add unit test ForceForwardAllQueriesTest

Unit Test:
- ForceForwardAllQueriesTest passed (4 scenarios)
- Full FE build with checkstyle passed
@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?

@yujun777

Copy link
Copy Markdown
Contributor Author

run buildall

@morrySnow morrySnow changed the title [feature](fe) Support session level force_forward_all_queries [feature](query) Support session level force_forward_all_queries Aug 12, 2026
@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Aug 12, 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.

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17604	3913	3887	3887
q2	2063	325	205	205
q3	10244	1347	779	779
q4	4684	473	341	341
q5	7505	811	556	556
q6	177	165	134	134
q7	699	803	594	594
q8	9594	1541	1576	1541
q9	6018	4066	4009	4009
q10	6727	1620	1350	1350
q11	503	348	331	331
q12	739	599	451	451
q13	18093	3224	2708	2708
q14	259	252	238	238
q15	q16	731	726	659	659
q17	1031	921	1045	921
q18	6632	5632	5573	5573
q19	1699	1246	1091	1091
q20	781	677	571	571
q21	6469	2607	2409	2409
q22	427	354	303	303
Total cold run time: 102679 ms
Total hot run time: 28651 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4286	4155	4151	4151
q2	272	319	209	209
q3	4509	4888	4391	4391
q4	2163	2217	1404	1404
q5	4243	4131	4155	4131
q6	237	175	122	122
q7	1705	1599	1538	1538
q8	2544	2048	2057	2048
q9	7193	7194	7225	7194
q10	4305	4267	3929	3929
q11	547	395	360	360
q12	710	740	533	533
q13	3255	3581	2954	2954
q14	285	308	287	287
q15	q16	683	708	638	638
q17	1323	1296	1287	1287
q18	12152	11048	11909	11048
q19	1236	1159	1154	1154
q20	2216	2219	1931	1931
q21	5583	4870	4798	4798
q22	514	466	412	412
Total cold run time: 59961 ms
Total hot run time: 54519 ms

@hello-stephen

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

query5	4326	592	477	477
query6	455	213	198	198
query7	4886	597	354	354
query8	317	162	165	162
query9	8755	3992	3904	3904
query10	453	355	316	316
query11	5837	2166	2017	2017
query12	155	98	96	96
query13	1259	583	430	430
query14	6050	4264	3936	3936
query14_1	3770	3796	3750	3750
query15	207	194	180	180
query16	978	467	481	467
query17	902	677	535	535
query18	2433	461	353	353
query19	210	209	177	177
query20	112	106	105	105
query21	233	159	139	139
query22	12975	13022	12743	12743
query23	16015	14981	14699	14699
query23_1	14657	14841	14674	14674
query24	7621	1700	1244	1244
query24_1	1247	1232	1243	1232
query25	557	440	379	379
query26	1331	375	207	207
query27	2591	606	381	381
query28	4540	2011	1994	1994
query29	1069	630	496	496
query30	339	263	229	229
query31	1179	1111	1042	1042
query32	117	63	68	63
query33	533	312	244	244
query34	1182	1118	639	639
query35	746	770	651	651
query36	770	774	702	702
query37	156	113	97	97
query38	1830	1771	1681	1681
query39	814	833	791	791
query39_1	785	775	793	775
query40	262	176	150	150
query41	71	68	102	68
query42	98	100	92	92
query43	308	318	273	273
query44	1432	766	751	751
query45	185	177	165	165
query46	1012	1164	708	708
query47	1619	1564	1448	1448
query48	406	418	299	299
query49	574	398	292	292
query50	1064	430	325	325
query51	10553	10203	10471	10203
query52	86	86	73	73
query53	257	263	190	190
query54	272	239	210	210
query55	76	72	66	66
query56	294	286	319	286
query57	1030	1016	920	920
query58	303	252	251	251
query59	1550	1530	1362	1362
query60	289	276	243	243
query61	150	145	147	145
query62	391	323	268	268
query63	241	199	201	199
query64	2861	996	858	858
query65	3882	3824	3781	3781
query66	1828	500	359	359
query67	20175	19920	19880	19880
query68	3157	1548	958	958
query69	404	300	261	261
query70	880	795	739	739
query71	374	334	318	318
query72	3029	2631	2301	2301
query73	852	749	438	438
query74	4656	4510	4279	4279
query75	2378	2348	1982	1982
query76	2333	1149	753	753
query77	337	365	255	255
query78	11180	11099	10703	10703
query79	1370	1091	785	785
query80	1128	539	452	452
query81	501	340	288	288
query82	640	173	133	133
query83	401	316	291	291
query84	328	157	130	130
query85	972	590	495	495
query86	376	240	222	222
query87	2000	1972	1832	1832
query88	3703	2773	2752	2752
query89	406	314	278	278
query90	1784	206	188	188
query91	200	191	158	158
query92	69	57	57	57
query93	1556	1451	977	977
query94	646	362	314	314
query95	810	604	466	466
query96	1026	843	355	355
query97	2461	2475	2354	2354
query98	199	187	182	182
query99	737	737	616	616
Total cold run time: 244808 ms
Total hot run time: 157467 ms

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage `` 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.10	0.05	0.05
query3	0.25	0.13	0.13
query4	1.61	0.14	0.14
query5	0.24	0.22	0.21
query6	1.16	0.82	0.80
query7	0.04	0.01	0.00
query8	0.06	0.04	0.04
query9	0.38	0.31	0.33
query10	0.59	0.59	0.53
query11	0.18	0.14	0.13
query12	0.18	0.14	0.14
query13	0.45	0.45	0.46
query14	1.00	0.98	1.00
query15	0.61	0.57	0.58
query16	0.32	0.32	0.30
query17	1.07	1.05	1.05
query18	0.21	0.21	0.20
query19	2.01	1.93	1.97
query20	0.02	0.01	0.01
query21	15.46	0.17	0.13
query22	5.01	0.06	0.06
query23	16.11	0.30	0.12
query24	2.99	0.41	0.31
query25	0.11	0.05	0.04
query26	0.74	0.20	0.14
query27	0.03	0.03	0.05
query28	3.51	0.80	0.34
query29	12.48	3.99	3.19
query30	0.27	0.16	0.16
query31	2.77	0.56	0.32
query32	3.22	0.60	0.51
query33	3.27	3.14	3.16
query34	15.63	4.00	3.31
query35	3.20	3.23	3.22
query36	0.57	0.43	0.43
query37	0.09	0.06	0.07
query38	0.05	0.04	0.03
query39	0.04	0.03	0.03
query40	0.17	0.16	0.15
query41	0.09	0.04	0.04
query42	0.04	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 96.38 s
Total hot run time: 23.8 s

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

Labels

approved Indicates a PR has been approved by one committer. dev/4.0.x dev/4.1.x reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants