Skip to content

[fix](hdfs) Remove query profile from HDFS file reader - #67335

Merged
gavinchou merged 1 commit into
apache:masterfrom
bobhan1:fix/doris-28268-hdfs-prefetch-profile-uaf-master
Aug 31, 2026
Merged

[fix](hdfs) Remove query profile from HDFS file reader#67335
gavinchou merged 1 commit into
apache:masterfrom
bobhan1:fix/doris-28268-hdfs-prefetch-profile-uaf-master

Conversation

@bobhan1

@bobhan1 bobhan1 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: #67293

Problem Summary:

CachedRemoteFileReader::prefetch_range() submits fire-and-forget dry-run tasks. A running task keeps the cached reader and its underlying HdfsFileReader alive, but it does not keep the query RuntimeProfile alive. Because HdfsFileReader stored raw pointers to query-profile timers and counters, a delayed prefetch read could update them after the query profile had been destroyed and trigger a use-after-free.

Remove the query RuntimeProfile dependency and HDFS-specific query-profile timers and counters from HdfsFileReader. This also removes the now-unused profile passthrough from HdfsFileSystem and updates all affected call sites. Generic file-reader and file-cache statistics plus process-wide HDFS bvars remain unchanged; HDFS reads and cache behavior are unchanged.

The forward-port conflict in hdfs_file_reader.cpp was resolved by preserving master's WorkloadGroup/ResourceContext includes and master's removal of the old compile_check_begin/end pair while applying #67293's profile-removal semantics.

Release note

None

Check List (For Author)

  • Test
    • Regression test
    • Unit Test
    • Manual test
      • build-support/clang-format.sh
      • build-support/check-format.sh
      • build-support/check-build-hygiene.sh
      • git diff --check upstream/master...HEAD
      • ./build.sh --be -j100 with the existing Release build type
    • No need to test or manual test
  • Behavior changed:
    • No
    • Yes. Query profiles no longer expose the HDFS-specific HdfsIO timer and HDFS read-statistics counters. HDFS reads and file-cache behavior are unchanged.
  • 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?

### What problem does this PR solve?

Issue Number: None

Related PR: apache#67293

Problem Summary: `CachedRemoteFileReader::prefetch_range()` submits fire-and-forget dry-run tasks that can outlive the query `RuntimeProfile`. `HdfsFileReader` stored raw pointers to query-profile timers and counters, so a delayed prefetch read could update them after the query profile had been destroyed and trigger a use-after-free. Remove the query `RuntimeProfile` dependency and HDFS-specific query-profile timers and counters from `HdfsFileReader`, remove the unused profile passthrough from `HdfsFileSystem`, and update all affected call sites. Generic file-reader and file-cache statistics plus process-wide HDFS bvars remain unchanged.

### Release note

None

### Check List (For Author)

- Test: Manual test
    - `build-support/clang-format.sh`
    - `build-support/check-format.sh`
    - `build-support/check-build-hygiene.sh`
    - `git diff --check upstream/master...HEAD`
- Behavior changed: Yes. Query profiles no longer expose the HDFS-specific `HdfsIO` timer and HDFS read-statistics counters; HDFS reads and file-cache behavior are unchanged.
- Does this need documentation: No

(cherry picked from commit 4e45489)
@bobhan1
bobhan1 force-pushed the fix/doris-28268-hdfs-prefetch-profile-uaf-master branch from 4dcc5db to 096a785 Compare August 31, 2026 07:49
@bobhan1

bobhan1 commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

yiguolei pushed a commit that referenced this pull request Aug 31, 2026
…67293)

### What problem does this PR solve?
pick #67335

Issue Number: DORIS-28268

Related PR: None

Problem Summary:

`CachedRemoteFileReader::prefetch_range()` submits fire-and-forget
dry-run tasks. A running task keeps the cached reader and its underlying
`HdfsFileReader` alive, but it does not keep the query `RuntimeProfile`
alive. Because `HdfsFileReader` stored raw pointers to query-profile
timers and counters, a delayed prefetch read could update them after the
query profile had been destroyed and trigger a use-after-free.

Remove the query `RuntimeProfile` dependency and HDFS-specific
query-profile timers/counters from `HdfsFileReader`. This also removes
the now-unused profile passthrough from `HdfsFileSystem` and updates all
affected call sites. Generic file-reader/file-cache statistics and
process-wide HDFS bvars remain unchanged; HDFS reads and cache behavior
are unchanged.

### Release note

None

### Check List (For Author)

- Test
    - [ ] Regression test
    - [ ] Unit Test
    - [x] Manual test (add detailed scripts or steps below)
        - `clang-format --dry-run --Werror` on all changed C++ files
        - `git diff --check`
- `./build.sh --be -j100`: the changed HDFS reader/filesystem and
affected call-site translation units compiled successfully. The full
local BE build is blocked by an unrelated installed Lance C header
mismatch (`LanceScanStatistics` and statistics callback definitions are
missing from the local `lance.h`).
    - [ ] 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.
- [x] Yes. Query profiles no longer expose the HDFS-specific `HdfsIO`
timer and HDFS read-statistics counters. HDFS read and file-cache
behavior are unchanged.

- Does this need documentation?
    - [x] No.
    - [ ] Yes.

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
@bobhan1
bobhan1 marked this pull request as ready for review August 31, 2026 10:23
@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 42.86% (3/7) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.08% (34492/45334)
Line Coverage 61.05% (388515/636346)
Region Coverage 57.11% (325663/570232)
Branch Coverage 57.96% (148655/256458)

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17573	3004	2986	2986
q2	2119	281	238	238
q3	10189	895	529	529
q4	4664	262	202	202
q5	7672	591	384	384
q6	143	117	97	97
q7	540	522	385	385
q8	9250	918	1013	918
q9	3590	2463	2436	2436
q10	6526	860	716	716
q11	390	199	181	181
q12	610	270	197	197
q13	18144	1564	1179	1179
q14	160	154	139	139
q15	q16	435	405	375	375
q17	1395	911	813	813
q18	3193	2333	2326	2326
q19	1123	940	816	816
q20	364	298	201	201
q21	4925	1693	1855	1693
q22	325	281	230	230
Total cold run time: 93330 ms
Total hot run time: 17041 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3350	3270	3292	3270
q2	523	398	370	370
q3	2364	2404	2243	2243
q4	1250	1224	920	920
q5	2266	2185	2201	2185
q6	173	125	88	88
q7	1035	923	891	891
q8	1629	1442	1446	1442
q9	3285	3273	3246	3246
q10	1943	1838	1700	1700
q11	364	275	252	252
q12	461	440	355	355
q13	1521	1596	1139	1139
q14	179	176	162	162
q15	q16	403	402	363	363
q17	3738	3478	3317	3317
q18	5041	4590	5107	4590
q19	980	870	849	849
q20	1034	996	845	845
q21	3863	3262	3247	3247
q22	409	355	324	324
Total cold run time: 35811 ms
Total hot run time: 31798 ms

@hello-stephen

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

query5	4256	415	324	324
query6	380	142	129	129
query7	4960	428	223	223
query8	292	126	119	119
query9	8682	2902	2850	2850
query10	382	235	188	188
query11	5374	1075	934	934
query12	115	74	72	72
query13	1192	458	299	299
query14	6137	2261	2136	2136
query14_1	2047	2033	2017	2017
query15	179	123	117	117
query16	936	392	354	354
query17	822	472	374	374
query18	2351	334	256	256
query19	166	145	113	113
query20	83	69	70	69
query21	202	102	87	87
query22	5500	5491	5440	5440
query23	6911	6408	6205	6205
query23_1	6256	6094	6369	6094
query24	7255	1066	778	778
query24_1	775	785	776	776
query25	409	282	234	234
query26	1230	245	127	127
query27	2780	427	259	259
query28	4685	1510	1487	1487
query29	915	429	342	342
query30	241	156	130	130
query31	837	404	337	337
query32	129	75	74	74
query33	464	210	168	168
query34	994	798	478	478
query35	405	418	343	343
query36	574	562	509	509
query37	117	82	72	72
query38	1018	881	840	840
query39	490	494	491	491
query39_1	477	470	463	463
query40	202	93	75	75
query41	54	52	50	50
query42	76	73	76	73
query43	243	245	210	210
query44	990	536	554	536
query45	109	109	102	102
query46	780	833	514	514
query47	753	772	712	712
query48	301	323	226	226
query49	521	247	189	189
query50	753	257	193	193
query51	7991	8010	7962	7962
query52	68	70	59	59
query53	195	204	150	150
query54	242	186	182	182
query55	89	66	58	58
query56	224	174	179	174
query57	699	681	674	674
query58	205	185	164	164
query59	1280	1269	1133	1133
query60	267	217	182	182
query61	114	116	115	115
query62	344	208	188	188
query63	172	146	145	145
query64	2713	702	596	596
query65	1755	1730	1676	1676
query66	1873	259	199	199
query67	10011	10094	9949	9949
query68	3002	1219	760	760
query69	332	221	201	201
query70	681	622	635	622
query71	253	178	164	164
query72	2380	1736	1597	1597
query73	680	586	354	354
query74	1983	1238	1159	1159
query75	1186	1120	979	979
query76	2355	725	567	567
query77	248	262	218	218
query78	4160	3889	3387	3387
query79	2586	866	606	606
query80	1543	343	274	274
query81	493	161	135	135
query82	613	133	99	99
query83	287	204	194	194
query84	291	110	88	88
query85	777	355	290	290
query86	382	165	174	165
query87	1026	1001	933	933
query88	2777	2097	2104	2097
query89	292	195	178	178
query90	1988	122	129	122
query91	132	119	97	97
query92	79	69	71	69
query93	1441	1128	751	751
query94	648	264	227	227
query95	519	256	230	230
query96	830	559	264	264
query97	1102	1115	1027	1027
query98	169	134	132	132
query99	425	349	311	311
Total cold run time: 179118 ms
Total hot run time: 83296 ms

@hello-stephen

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

query1	0.00	0.01	0.01
query2	0.07	0.04	0.03
query3	0.24	0.10	0.10
query4	1.60	0.10	0.09
query5	0.17	0.16	0.17
query6	1.26	0.71	0.68
query7	0.03	0.00	0.01
query8	0.05	0.03	0.03
query9	0.29	0.22	0.21
query10	0.35	0.34	0.33
query11	0.16	0.11	0.12
query12	0.15	0.12	0.12
query13	0.32	0.33	0.31
query14	0.46	0.46	0.47
query15	0.37	0.34	0.34
query16	0.23	0.23	0.22
query17	0.74	0.70	0.70
query18	0.18	0.17	0.15
query19	1.21	1.17	1.09
query20	0.02	0.01	0.01
query21	15.43	0.15	0.12
query22	5.09	0.05	0.04
query23	16.18	0.25	0.10
query24	3.02	0.31	0.26
query25	0.10	0.05	0.04
query26	0.80	0.17	0.11
query27	0.03	0.03	0.03
query28	3.62	0.56	0.28
query29	12.49	3.19	2.57
query30	0.26	0.12	0.13
query31	2.76	0.37	0.17
query32	3.52	0.32	0.25
query33	1.39	1.39	1.44
query34	15.38	2.21	1.80
query35	1.77	1.75	1.75
query36	0.45	0.28	0.29
query37	0.06	0.04	0.04
query38	0.04	0.03	0.03
query39	0.04	0.02	0.02
query40	0.11	0.08	0.07
query41	0.07	0.02	0.03
query42	0.03	0.02	0.02
query43	0.03	0.03	0.02
Total cold run time: 90.57 s
Total hot run time: 14.68 s

@gavinchou
gavinchou merged commit ac948fe into apache:master Aug 31, 2026
33 of 35 checks passed
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