Skip to content

[test](be) Set the thread counts in TimeSharingTaskExecutorTest.test_invalid_task_handle_returns_error - #69915

Merged
hello-stephen merged 1 commit into
apache:masterfrom
morningman:b2m-t37i-time-sharing-test-threads
Nov 1, 2026
Merged

hello-stephen merged 1 commit into
apache:masterfrom
morningman:b2m-t37i-time-sharing-test-threads

Conversation

@morningman

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: #65054

Problem Summary:

In short: TimeSharingTaskExecutorTest.test_invalid_task_handle_returns_error builds its executor from a ThreadConfig whose thread counts are never set, so BE UT runs intermittently die in it with a core dump. This PR sets the two counts in the test.

Background: TimeSharingTaskExecutor::ThreadConfig::max_thread_num and min_thread_num are plain int fields without a default value. The other ten ThreadConfigs in time_sharing_task_executor_test.cpp set both; the test added by #65054 sets only thread_name and workload_group before calling init().

The problem, and what it cost: init() sizes the thread pool from whatever the stack holds. When that value is large, it keeps creating threads until mmap fails:

==38657==ERROR: AddressSanitizer failed to allocate 0xfc000 (1032192) bytes at address 0x0f63acfd7000 (errno: 12)
==38657==ERROR: AddressSanitizer: SEGV on unknown address 0x0ab44632aa9e ...

TeamCity then reports Build stopped: CORE DUMPED, and no suite scheduled after this test runs, so the run says nothing about the PR's own BE tests that come later. Between 2026-10-24 and 10-31 this happened in 4 of 11 sampled BE UT runs, on four different PRs (build 1087538 on #69581 is one); a rerun passes.

How this PR fixes it: set max_thread_num and min_thread_num to 0, as test_remove_task_clears_queued_task_count in the same file does. The test only calls init() and checks that null and foreign task handles are rejected, so it needs no worker thread. Test-only change; the executor is unchanged.

Results:

Before After
Thread counts of the test's executor whatever the stack holds 0 / 0
BE UT aborts in this test in some runs (4 of 11 sampled) the test no longer depends on stack contents

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

    run-be-ut.sh --run --filter='TimeSharingTaskExecutorTest.*' on macOS arm64 (ASAN): 13 tests pass.

  • 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

…invalid_task_handle_returns_error

### What problem does this PR solve?

Issue Number: None

Related PR: apache#65054

Problem Summary:

BE UT intermittently stops with "Build stopped: CORE DUMPED" in
`TimeSharingTaskExecutorTest.test_invalid_task_handle_returns_error`:
AddressSanitizer reports `failed to allocate 0xfc000 (1032192) bytes ...
(errno: 12)` twice and then a SEGV, and no suite after it runs. Between
2026-10-24 and 10-31 this happened in 4 of 11 sampled BE UT runs, on four
different PRs; a rerun passes.

Root cause: `TimeSharingTaskExecutor::ThreadConfig::max_thread_num` and
`min_thread_num` have no default value. The test, added by apache#65054, sets only
`thread_name` and `workload_group`, so `init()` sizes the thread pool from
whatever the stack holds and keeps creating threads until mmap fails. The
other ten `ThreadConfig`s in the file set both counts.

Fix: set both counts to 0, as `test_remove_task_clears_queued_task_count`
does. The test only calls `init()` and checks that null and foreign task
handles are rejected, so it needs no worker thread. Test-only change.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - `run-be-ut.sh --run --filter='TimeSharingTaskExecutorTest.*'` on macOS
      arm64 (ASAN): 13 tests pass.
- Behavior changed: No
- Does this need documentation: No

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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?

@morningman

Copy link
Copy Markdown
Contributor Author

run buildall

@morningman

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.

Static review completed for PR #69915 at exact head 40e7107. The two added assignments initialize the previously indeterminate ThreadConfig max/min thread counts in test_invalid_task_handle_returns_error. A 0/0 configuration is valid for this queue-only validation test: init creates no workers, start is a no-op, and stop/destruction safely quiesce the idle token. All null and invalid handle calls return from get_time_sharing_task_handle before queue submission or worker-dependent logic, so the assertions retain their intended coverage. The change is small and focused, introduces no data, concurrency, lifecycle, compatibility, error-handling, observability, or performance issue, and no parallel ThreadConfig construction remains uninitialized. No user-provided focus points were supplied. Existing inline P0/P1 findings: none. Tests were inspected but not executed under the static-only review contract.

Review converged after 1 round(s).

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17561	5088	5008	5008
q2	2130	300	253	253
q3	10254	1372	807	807
q4	4680	462	346	346
q5	7428	799	527	527
q6	182	185	152	152
q7	735	794	597	597
q8	9276	1353	1131	1131
q9	6089	4179	4175	4175
q10	6809	1282	1028	1028
q11	424	250	224	224
q12	637	391	277	277
q13	18105	3562	3033	3033
q14	271	269	240	240
q15	q16	721	714	665	665
q17	1194	748	572	572
q18	6931	6149	6122	6122
q19	1102	952	619	619
q20	379	323	223	223
q21	4879	2106	2260	2106
q22	340	291	252	252
Total cold run time: 100127 ms
Total hot run time: 28357 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5600	5580	5584	5580
q2	680	564	506	506
q3	5178	5378	4955	4955
q4	1988	2137	1560	1560
q5	5260	5145	5523	5145
q6	270	225	166	166
q7	2363	2054	1870	1870
q8	3016	2730	2662	2662
q9	8042	7942	7977	7942
q10	3822	3667	3256	3256
q11	625	474	415	415
q12	684	722	531	531
q13	3557	3871	3342	3342
q14	317	330	292	292
q15	q16	723	706	644	644
q17	8318	7065	6844	6844
q18	12955	12151	12882	12151
q19	895	776	775	775
q20	2130	2141	1908	1908
q21	5597	4545	4627	4545
q22	491	432	419	419
Total cold run time: 72511 ms
Total hot run time: 65508 ms

@hello-stephen

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

query5	4313	571	423	423
query6	422	215	188	188
query7	4804	462	222	222
query8	320	161	143	143
query9	8790	3157	3145	3145
query10	496	308	279	279
query11	5967	3887	3576	3576
query12	148	94	102	94
query13	1246	442	325	325
query14	6113	3891	3664	3664
query14_1	3403	3412	3422	3412
query15	207	201	184	184
query16	947	426	387	387
query17	836	675	586	586
query18	2411	420	324	324
query19	199	170	143	143
query20	88	85	85	85
query21	210	129	106	106
query22	13107	12995	12820	12820
query23	13400	12807	12411	12411
query23_1	12482	12438	12464	12438
query24	7409	831	481	481
query24_1	486	478	478	478
query25	540	458	347	347
query26	1251	251	133	133
query27	2795	435	267	267
query28	4644	2023	1977	1977
query29	1556	572	430	430
query30	286	219	180	180
query31	1009	930	806	806
query32	143	88	87	87
query33	516	288	228	228
query34	935	875	514	514
query35	741	752	629	629
query36	809	801	716	716
query37	120	91	81	81
query38	1767	1742	1679	1679
query39	784	807	758	758
query39_1	752	728	739	728
query40	215	125	92	92
query41	67	63	62	62
query42	89	86	82	82
query43	342	359	313	313
query44	1313	687	700	687
query45	173	186	174	174
query46	845	980	577	577
query47	2806	2862	2874	2862
query48	310	324	227	227
query49	576	426	299	299
query50	714	283	222	222
query51	10631	10581	10812	10581
query52	78	80	78	78
query53	183	209	156	156
query54	227	208	178	178
query55	72	69	71	69
query56	246	224	229	224
query57	1643	1614	1581	1581
query58	320	281	254	254
query59	2233	2258	2058	2058
query60	284	242	235	235
query61	150	151	147	147
query62	390	329	288	288
query63	185	159	157	157
query64	2769	964	780	780
query65	3304	3302	3251	3251
query66	1790	431	300	300
query67	20172	20244	20028	20028
query68	2922	988	622	622
query69	406	288	249	249
query70	836	788	751	751
query71	289	229	215	215
query72	2774	2738	2492	2492
query73	515	520	302	302
query74	4642	4508	4363	4363
query75	2362	2313	1915	1915
query76	2319	1002	596	596
query77	349	399	278	278
query78	9633	9603	9137	9137
query79	1006	853	523	523
query80	1315	450	344	344
query81	570	327	272	272
query82	616	133	112	112
query83	293	192	173	173
query84	296	129	98	98
query85	883	445	381	381
query86	396	235	232	232
query87	2016	1929	1792	1792
query88	3815	2771	2754	2754
query89	330	278	242	242
query90	1922	169	161	161
query91	165	150	125	125
query92	97	89	90	89
query93	1041	991	567	567
query94	628	307	261	261
query95	580	385	297	297
query96	681	480	239	239
query97	2448	2464	2303	2303
query98	159	151	147	147
query99	770	758	659	659
Total cold run time: 235407 ms
Total hot run time: 151478 ms

@hello-stephen

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

query1	0.00	0.00	0.01
query2	0.08	0.05	0.05
query3	0.26	0.09	0.09
query4	1.61	0.11	0.10
query5	0.24	0.24	0.24
query6	1.17	0.68	0.67
query7	0.04	0.00	0.00
query8	0.06	0.04	0.03
query9	0.41	0.34	0.33
query10	0.60	0.60	0.58
query11	0.21	0.14	0.15
query12	0.18	0.17	0.14
query13	0.48	0.48	0.48
query14	1.04	1.00	1.00
query15	0.62	0.62	0.62
query16	0.35	0.35	0.35
query17	1.11	1.18	1.09
query18	0.21	0.20	0.20
query19	2.06	1.94	2.04
query20	0.02	0.02	0.01
query21	15.42	0.19	0.14
query22	4.92	0.05	0.06
query23	16.28	0.33	0.13
query24	2.75	0.67	0.35
query25	0.12	0.06	0.06
query26	1.54	0.23	0.15
query27	0.05	0.05	0.04
query28	2.95	0.68	0.36
query29	12.46	4.14	3.26
query30	0.27	0.14	0.11
query31	2.77	0.56	0.31
query32	3.22	0.60	0.49
query33	3.14	3.15	3.22
query34	15.32	4.01	3.39
query35	3.35	3.36	3.34
query36	0.59	0.43	0.44
query37	0.09	0.06	0.06
query38	0.05	0.04	0.03
query39	0.04	0.03	0.03
query40	0.19	0.15	0.14
query41	0.09	0.03	0.02
query42	0.04	0.03	0.02
query43	0.04	0.03	0.04
Total cold run time: 96.44 s
Total hot run time: 24.15 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 77.70% (36722/47259)
Line Coverage 63.04% (415863/659732)
Region Coverage 59.36% (351359/591917)
Branch Coverage 60.31% (163118/270480)

@morningman
morningman requested a review from Gabriel39 November 1, 2026 23:41
@hello-stephen
hello-stephen merged commit 347b9a0 into apache:master Nov 1, 2026
38 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.

2 participants