Skip to content

[fix] Preserve CurrentConnected in frontends() TVF#61087

Open
deardeng wants to merge 2 commits intoapache:masterfrom
deardeng:fix-frontends-tvf
Open

[fix] Preserve CurrentConnected in frontends() TVF#61087
deardeng wants to merge 2 commits intoapache:masterfrom
deardeng:fix-frontends-tvf

Conversation

@deardeng
Copy link
Contributor

@deardeng deardeng commented Mar 5, 2026

Cause:

  • FRONTENDS() goes through metadata scan and may be generated on master FE.
  • In this path, currentConnectedFE context is not always preserved, so CurrentConnected falls back to master and WHERE CURRENTCONNECTED='Yes' always matches master.

Fix:

  • Reuse TFrontendsMetadataParams.cluster_name as a pass-through slot to carry the FE host that accepted the client connection from TVF planning to metadata generation.
  • Populate this host in FrontendsTableValuedFunction#getMetaScanRange (prefer ConnectContext.currentConnectedFEIp, fallback to self host).
  • Read and apply it in MetadataGenerator#frontendsMetadataResult via FrontendsProcNode#getFrontendsInfo(env, infos, currentConnectedFeHost).
  • Add comments at write/read points to explain why cluster_name is reused for this pass-through.

Verification:

  • FE UT: org.apache.doris.tablefunction.FrontendsTableValuedFunctionTest

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

Cause:
- FRONTENDS() goes through metadata scan and may be generated on master FE.
- In this path, currentConnectedFE context is not always preserved, so CurrentConnected falls back to master and WHERE CURRENTCONNECTED='Yes' always matches master.

Fix:
- Reuse TFrontendsMetadataParams.cluster_name as a pass-through slot to carry the FE host that accepted the client connection from TVF planning to metadata generation.
- Populate this host in FrontendsTableValuedFunction#getMetaScanRange (prefer ConnectContext.currentConnectedFEIp, fallback to self host).
- Read and apply it in MetadataGenerator#frontendsMetadataResult via FrontendsProcNode#getFrontendsInfo(env, infos, currentConnectedFeHost).
- Add comments at write/read points to explain why cluster_name is reused for this pass-through.

Verification:
- FE UT: org.apache.doris.tablefunction.FrontendsTableValuedFunctionTest
@hello-stephen
Copy link
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
Copy link
Contributor Author

deardeng commented Mar 5, 2026

run buildall

@doris-robot
Copy link

TPC-H: Total hot run time: 27589 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: http://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 85eb56275e09583b163f0bf6a8c48a4dab39e923, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17681	4589	4296	4296
q2	q3	10642	816	519	519
q4	4681	370	275	275
q5	7549	1204	1011	1011
q6	174	177	147	147
q7	769	839	671	671
q8	9311	1411	1294	1294
q9	4781	4753	4700	4700
q10	6242	1881	1676	1676
q11	478	260	246	246
q12	714	579	482	482
q13	18064	2889	2187	2187
q14	237	241	222	222
q15	928	797	805	797
q16	729	729	662	662
q17	722	885	401	401
q18	5797	5340	5215	5215
q19	1260	1019	600	600
q20	495	508	395	395
q21	4730	2059	1504	1504
q22	387	354	289	289
Total cold run time: 96371 ms
Total hot run time: 27589 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4761	4635	4500	4500
q2	q3	3853	4308	3829	3829
q4	902	1207	783	783
q5	4052	4350	4408	4350
q6	186	178	141	141
q7	1807	1646	1515	1515
q8	2470	2695	2710	2695
q9	7438	7372	7681	7372
q10	3810	4018	3679	3679
q11	510	441	476	441
q12	526	605	460	460
q13	2737	3119	2320	2320
q14	274	310	283	283
q15	853	786	835	786
q16	714	765	707	707
q17	1181	1482	1374	1374
q18	7085	6810	6644	6644
q19	862	885	895	885
q20	2175	2174	2002	2002
q21	4165	3500	3365	3365
q22	466	457	381	381
Total cold run time: 50827 ms
Total hot run time: 48512 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 153300 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: http://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 85eb56275e09583b163f0bf6a8c48a4dab39e923, data reload: false

query5	4321	647	524	524
query6	320	233	217	217
query7	4214	516	272	272
query8	338	258	238	238
query9	8751	2731	2735	2731
query10	464	374	337	337
query11	7406	5849	5611	5611
query12	193	129	127	127
query13	1279	453	350	350
query14	5758	3832	3589	3589
query14_1	2823	2831	2803	2803
query15	209	195	179	179
query16	1007	492	475	475
query17	1106	740	620	620
query18	2514	446	346	346
query19	214	212	202	202
query20	137	134	131	131
query21	236	145	132	132
query22	4745	5079	4678	4678
query23	16002	15651	15287	15287
query23_1	15376	16352	15982	15982
query24	7771	1732	1319	1319
query24_1	1343	1316	1313	1313
query25	637	530	472	472
query26	1425	322	173	173
query27	3281	521	303	303
query28	4822	1985	1888	1888
query29	863	562	480	480
query30	317	247	210	210
query31	1361	1278	1220	1220
query32	84	70	74	70
query33	508	330	275	275
query34	933	930	570	570
query35	628	671	601	601
query36	1058	1146	1000	1000
query37	130	94	83	83
query38	2969	2928	2883	2883
query39	889	893	839	839
query39_1	839	834	810	810
query40	230	154	136	136
query41	63	70	57	57
query42	299	302	302	302
query43	243	263	225	225
query44	
query45	195	191	181	181
query46	868	1009	611	611
query47	2112	2112	2027	2027
query48	300	317	237	237
query49	631	458	383	383
query50	661	276	210	210
query51	4105	4094	4030	4030
query52	288	290	286	286
query53	297	333	282	282
query54	306	274	287	274
query55	87	83	87	83
query56	329	317	316	316
query57	1365	1379	1303	1303
query58	295	278	286	278
query59	1313	1476	1302	1302
query60	345	336	322	322
query61	155	147	154	147
query62	619	592	556	556
query63	318	279	275	275
query64	5135	1294	1005	1005
query65	
query66	1468	454	354	354
query67	16531	16636	16551	16551
query68	
query69	410	307	281	281
query70	931	923	987	923
query71	347	314	308	308
query72	2915	2724	2467	2467
query73	540	535	315	315
query74	10071	10038	9816	9816
query75	2863	2748	2457	2457
query76	2284	1019	691	691
query77	388	381	307	307
query78	11218	11537	10748	10748
query79	1147	796	597	597
query80	1503	647	555	555
query81	575	274	245	245
query82	985	152	116	116
query83	357	272	241	241
query84	253	115	96	96
query85	1055	506	439	439
query86	406	313	332	313
query87	3179	3090	3025	3025
query88	3511	2662	2635	2635
query89	427	379	346	346
query90	1904	180	194	180
query91	175	165	138	138
query92	78	72	70	70
query93	1020	882	507	507
query94	671	324	281	281
query95	582	400	316	316
query96	646	513	225	225
query97	2480	2491	2434	2434
query98	237	217	224	217
query99	1024	1003	937	937
Total cold run time: 235152 ms
Total hot run time: 153300 ms

Background:\nFRONTENDS() previously reused TFrontendsMetadataParams.cluster_name to pass\nthe FE host that accepted the client connection. This made the semantics\nof cluster_name ambiguous and fragile.\n\nFix:\n- add optional field current_connected_fe_host to TFrontendsMetadataParams\n- write this field in FrontendsTableValuedFunction\n- read this field in MetadataGenerator when building FRONTENDS() rows\n- update FrontendsTableValuedFunctionTest assertions\n\nCompatibility:\ncluster_name remains unchanged for compatibility; CurrentConnected now uses\na dedicated field with explicit meaning.
@deardeng
Copy link
Contributor Author

deardeng commented Mar 5, 2026

run buildall

@hello-stephen
Copy link
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 79.35% (1798/2266)
Line Coverage 64.51% (32195/49910)
Region Coverage 65.38% (16118/24653)
Branch Coverage 55.89% (8584/15360)

@doris-robot
Copy link

TPC-H: Total hot run time: 27744 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: http://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit b08573f572c3816e28a0246ff397830ef35cdd9c, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17628	4534	4385	4385
q2	q3	10729	893	530	530
q4	4724	369	256	256
q5	8177	1227	1022	1022
q6	236	175	146	146
q7	805	872	657	657
q8	10699	1513	1368	1368
q9	6678	4787	4734	4734
q10	6592	1929	1655	1655
q11	469	268	237	237
q12	772	574	470	470
q13	18068	2937	2199	2199
q14	238	238	208	208
q15	922	804	812	804
q16	773	720	675	675
q17	768	875	406	406
q18	6023	5318	5170	5170
q19	1220	1001	622	622
q20	500	496	403	403
q21	4628	1986	1512	1512
q22	400	309	285	285
Total cold run time: 101049 ms
Total hot run time: 27744 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4762	4619	4565	4565
q2	q3	3910	4377	3847	3847
q4	896	1215	833	833
q5	4128	4402	4340	4340
q6	195	182	149	149
q7	1816	1617	1537	1537
q8	2480	2863	2541	2541
q9	7676	7397	7408	7397
q10	3835	3966	3586	3586
q11	519	428	427	427
q12	510	583	442	442
q13	2694	3189	2334	2334
q14	315	346	290	290
q15	875	801	804	801
q16	722	783	737	737
q17	1216	1514	1340	1340
q18	7092	6811	6718	6718
q19	946	919	894	894
q20	2105	2195	2182	2182
q21	4041	3524	3492	3492
q22	454	431	379	379
Total cold run time: 51187 ms
Total hot run time: 48831 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 153463 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: http://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit b08573f572c3816e28a0246ff397830ef35cdd9c, data reload: false

query5	4318	640	527	527
query6	323	232	217	217
query7	4233	463	276	276
query8	359	241	223	223
query9	8644	2771	2791	2771
query10	523	375	336	336
query11	7425	5878	5577	5577
query12	185	126	124	124
query13	1262	452	374	374
query14	6358	3804	3607	3607
query14_1	2800	2769	2825	2769
query15	202	192	175	175
query16	975	476	452	452
query17	1073	702	613	613
query18	2592	470	332	332
query19	207	201	180	180
query20	136	128	128	128
query21	220	145	124	124
query22	4916	4913	4758	4758
query23	16717	16158	15758	15758
query23_1	15851	15805	15845	15805
query24	8080	1709	1287	1287
query24_1	1265	1250	1243	1243
query25	568	484	434	434
query26	1255	270	156	156
query27	2785	480	296	296
query28	4533	1926	1890	1890
query29	840	591	505	505
query30	308	254	216	216
query31	1366	1294	1224	1224
query32	78	79	74	74
query33	524	345	291	291
query34	954	961	579	579
query35	620	682	605	605
query36	1071	1076	977	977
query37	129	92	82	82
query38	2995	2916	2893	2893
query39	891	877	844	844
query39_1	836	838	843	838
query40	232	157	134	134
query41	62	59	58	58
query42	310	301	295	295
query43	241	274	228	228
query44	
query45	195	191	186	186
query46	906	992	630	630
query47	2113	2111	2049	2049
query48	341	320	235	235
query49	630	482	372	372
query50	689	278	208	208
query51	4282	4129	4058	4058
query52	290	289	281	281
query53	293	333	282	282
query54	307	278	264	264
query55	92	87	92	87
query56	310	313	302	302
query57	1365	1329	1277	1277
query58	288	285	269	269
query59	1339	1465	1318	1318
query60	338	332	318	318
query61	148	145	187	145
query62	633	592	528	528
query63	316	283	274	274
query64	4931	1258	997	997
query65	
query66	1417	458	356	356
query67	16483	16377	16607	16377
query68	
query69	385	326	291	291
query70	948	972	976	972
query71	333	307	304	304
query72	2741	2836	2467	2467
query73	557	559	332	332
query74	10015	9965	9751	9751
query75	2892	2774	2487	2487
query76	2302	1048	684	684
query77	375	426	329	329
query78	11164	11338	10676	10676
query79	1161	778	615	615
query80	739	662	561	561
query81	514	281	247	247
query82	1341	158	122	122
query83	391	277	255	255
query84	260	119	103	103
query85	930	561	519	519
query86	371	310	300	300
query87	3217	3093	3005	3005
query88	3638	2694	2690	2690
query89	427	371	353	353
query90	1952	181	185	181
query91	170	159	134	134
query92	78	78	76	76
query93	950	870	515	515
query94	463	325	290	290
query95	596	335	369	335
query96	647	528	230	230
query97	2486	2506	2393	2393
query98	227	214	212	212
query99	990	998	908	908
Total cold run time: 234641 ms
Total hot run time: 153463 ms

@doris-robot
Copy link

BE UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.56% (19646/37381)
Line Coverage 36.18% (183422/506986)
Region Coverage 32.46% (142214/438100)
Branch Coverage 33.42% (61719/184658)

@hello-stephen
Copy link
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.58% (26199/36603)
Line Coverage 54.34% (274648/505433)
Region Coverage 51.54% (227932/442237)
Branch Coverage 52.96% (98091/185222)

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 61.54% (8/13) 🎉
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.

4 participants