Skip to content

[refactor](close)Full refactor async writer - #30082

Merged
yiguolei merged 7 commits into
apache:masterfrom
yiguolei:full_refactor_async_writer
Jan 23, 2024
Merged

yiguolei merged 7 commits into
apache:masterfrom
yiguolei:full_refactor_async_writer

Conversation

@yiguolei

Copy link
Copy Markdown
Contributor

Proposed changes

Issue Number: close #xxx

Further comments

If this is a relatively large or complex change, kick off the discussion at [email protected] by explaining why you chose the solution you did and what alternatives you considered, etc...

@yiguolei

Copy link
Copy Markdown
Contributor Author

run buildall

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

clang-tidy made some suggestions

Comment thread be/src/pipeline/task_scheduler.cpp Resolved
@doris-robot

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

------ Round 1 ----------------------------------
q1	17657	6009	5430	5430
q2	2042	148	133	133
q3	10844	1173	1185	1173
q4	10228	781	798	781
q5	7784	3171	3180	3171
q6	198	124	123	123
q7	858	498	483	483
q8	9221	1932	1965	1932
q9	7211	6404	6387	6387
q10	8190	3043	3074	3043
q11	424	223	222	222
q12	354	192	197	192
q13	17996	3375	3371	3371
q14	235	211	214	211
q15	553	515	505	505
q16	478	383	395	383
q17	949	577	525	525
q18	7560	6931	6763	6763
q19	2226	1396	1440	1396
q20	563	316	310	310
q21	2742	2452	2438	2438
q22	372	318	316	316
Total cold run time: 108685 ms
Total hot run time: 39288 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5383	5303	5217	5217
q2	324	220	218	218
q3	3339	3179	3256	3179
q4	2065	2052	2067	2052
q5	6069	5927	5988	5927
q6	200	114	123	114
q7	2284	1849	1949	1849
q8	3215	3375	3409	3375
q9	8996	9115	8720	8720
q10	3962	3858	3851	3851
q11	570	452	443	443
q12	817	626	630	626
q13	16925	3178	3128	3128
q14	284	246	264	246
q15	561	506	503	503
q16	498	478	485	478
q17	1839	1872	1830	1830
q18	9603	9384	9521	9384
q19	22632	1576	1549	1549
q20	4612	1943	1902	1902
q21	14415	5252	5425	5252
q22	975	537	601	537
Total cold run time: 109568 ms
Total hot run time: 60380 ms

@doris-robot

Copy link
Copy Markdown
TPC-DS: Total hot run time: 176815 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 430bc9f1ed4343b4352a77af1ab014b017e605cc, data reload: false

query1	944	331	335	331
query2	6555	1912	1916	1912
query3	6699	204	194	194
query4	32539	22313	22075	22075
query5	6896	600	516	516
query6	249	167	169	167
query7	4606	271	264	264
query8	222	190	176	176
query9	8390	2583	2556	2556
query10	410	223	239	223
query11	16644	15558	15448	15448
query12	117	71	73	71
query13	1688	378	383	378
query14	10450	6988	7001	6988
query15	207	193	184	184
query16	4597	241	229	229
query17	988	483	479	479
query18	1779	262	260	260
query19	173	134	132	132
query20	72	71	69	69
query21	190	133	124	124
query22	4690	4740	4745	4740
query23	32006	30850	30763	30763
query24	5416	2838	2802	2802
query25	411	317	312	312
query26	720	144	150	144
query27	2230	269	271	269
query28	3985	1856	1847	1847
query29	911	636	616	616
query30	197	139	139	139
query31	896	731	760	731
query32	65	59	56	56
query33	348	213	211	211
query34	807	463	466	463
query35	874	783	756	756
query36	1303	1217	1238	1217
query37	101	61	59	59
query38	3356	3277	3267	3267
query39	1314	1269	1256	1256
query40	197	90	86	86
query41	41	35	34	34
query42	92	81	85	81
query43	494	481	485	481
query44	997	688	704	688
query45	196	181	174	174
query46	1057	650	632	632
query47	1660	1540	1562	1540
query48	392	318	320	318
query49	611	293	291	291
query50	670	306	308	306
query51	5367	5219	5257	5219
query52	91	82	77	77
query53	339	259	260	259
query54	733	436	458	436
query55	79	72	77	72
query56	176	167	176	167
query57	953	937	945	937
query58	188	156	160	156
query59	2924	2701	2717	2701
query60	206	191	186	186
query61	86	80	81	80
query62	453	356	361	356
query63	286	257	257	257
query64	2558	1793	1766	1766
query65	3335	3255	3277	3255
query66	875	322	318	318
query67	15443	15103	14668	14668
query68	12272	529	539	529
query69	615	310	292	292
query70	1633	1533	1545	1533
query71	523	209	210	209
query72	5051	2869	2866	2866
query73	3060	314	313	313
query74	6905	6363	6356	6356
query75	5313	2332	2292	2292
query76	6090	1049	1027	1027
query77	684	235	239	235
query78	9652	8660	8749	8660
query79	993	510	503	503
query80	614	322	328	322
query81	475	206	210	206
query82	203	78	76	76
query83	140	121	117	117
query84	278	69	67	67
query85	1074	326	311	311
query86	385	389	372	372
query87	3513	3370	3373	3370
query88	3097	2180	2155	2155
query89	430	361	349	349
query90	2261	187	186	186
query91	158	124	122	122
query92	50	42	44	42
query93	1926	430	453	430
query94	1412	165	156	156
query95	497	448	452	448
query96	626	323	312	312
query97	4259	4120	4124	4120
query98	199	202	187	187
query99	978	687	731	687
Total cold run time: 279910 ms
Total hot run time: 176815 ms

@doris-robot

Copy link
Copy Markdown

TeamCity be ut coverage result:
Function Coverage: 36.69% (8646/23567)
Line Coverage: 28.73% (70625/245790)
Region Coverage: 27.64% (36440/131854)
Branch Coverage: 24.35% (18644/76574)
Coverage Report: http://coverage.selectdb-in.cc/coverage/430bc9f1ed4343b4352a77af1ab014b017e605cc_430bc9f1ed4343b4352a77af1ab014b017e605cc/report/index.html

@doris-robot

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

query1	0.03	0.02	0.02
query2	0.06	0.02	0.03
query3	0.22	0.05	0.05
query4	1.70	0.06	0.06
query5	0.54	0.52	0.52
query6	1.34	0.63	0.63
query7	0.02	0.01	0.01
query8	0.03	0.02	0.02
query9	0.56	0.48	0.49
query10	0.55	0.56	0.56
query11	0.12	0.08	0.08
query12	0.11	0.09	0.09
query13	0.60	0.60	0.61
query14	0.78	0.78	0.80
query15	0.79	0.78	0.77
query16	0.37	0.38	0.37
query17	1.01	0.97	1.02
query18	0.24	0.27	0.25
query19	1.87	1.76	1.75
query20	0.01	0.01	0.01
query21	15.39	0.60	0.57
query22	2.52	2.61	1.50
query23	17.35	0.83	0.84
query24	2.45	0.26	0.43
query25	0.40	0.22	0.15
query26	0.39	0.14	0.14
query27	0.05	0.06	0.05
query28	12.91	0.76	0.76
query29	12.52	3.16	3.15
query30	0.52	0.50	0.53
query31	2.78	0.34	0.34
query32	3.38	0.50	0.48
query33	3.19	3.23	3.27
query34	15.84	4.25	4.22
query35	4.24	4.28	4.20
query36	1.11	1.08	1.08
query37	0.06	0.05	0.05
query38	0.04	0.02	0.03
query39	0.02	0.02	0.01
query40	0.17	0.15	0.13
query41	0.06	0.01	0.02
query42	0.03	0.01	0.02
query43	0.02	0.02	0.02
Total cold run time: 106.39 s
Total hot run time: 29.75 s

@doris-robot

Copy link
Copy Markdown

Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'

Load test result on commit 430bc9f1ed4343b4352a77af1ab014b017e605cc with default session variables
Stream load json:         19 seconds loaded 2358488459 Bytes, about 118 MB/s
Stream load orc:          58 seconds loaded 1101869774 Bytes, about 18 MB/s
Stream load parquet:      31 seconds loaded 861443392 Bytes, about 26 MB/s
Insert into select:       14.6 seconds inserted 10000000 Rows, about 684K ops/s

@yiguolei
yiguolei force-pushed the full_refactor_async_writer branch from 430bc9f to 12d3c90 Compare January 19, 2024 07:42
@yiguolei

Copy link
Copy Markdown
Contributor Author

run buildall

@doris-robot

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

------ Round 1 ----------------------------------
q1	17612	5367	5391	5367
q2	2047	163	144	144
q3	10622	1166	1162	1162
q4	10957	792	848	792
q5	7905	3205	3251	3205
q6	203	131	124	124
q7	891	513	496	496
q8	9510	1993	1999	1993
q9	7769	6569	6514	6514
q10	8614	3056	3032	3032
q11	414	237	215	215
q12	360	197	194	194
q13	17981	3362	3354	3354
q14	247	213	213	213
q15	552	513	504	504
q16	446	385	364	364
q17	946	544	548	544
q18	7683	6846	6812	6812
q19	1564	1339	1415	1339
q20	570	278	323	278
q21	2738	2398	2436	2398
q22	359	312	320	312
Total cold run time: 109990 ms
Total hot run time: 39356 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5370	5363	5261	5261
q2	329	215	211	211
q3	3340	3222	3238	3222
q4	2145	2079	2087	2079
q5	6112	5952	6011	5952
q6	216	114	118	114
q7	2258	1876	1807	1807
q8	3244	3404	3407	3404
q9	8938	8814	8830	8814
q10	3970	3895	3833	3833
q11	564	449	473	449
q12	828	643	645	643
q13	16945	3176	3176	3176
q14	288	259	257	257
q15	567	514	496	496
q16	527	488	468	468
q17	1876	1866	1822	1822
q18	9536	19737	9593	9593
q19	24029	1541	1542	1541
q20	4593	1952	1939	1939
q21	14505	5336	5355	5336
q22	981	589	568	568
Total cold run time: 111161 ms
Total hot run time: 60985 ms

@doris-robot

Copy link
Copy Markdown

TeamCity be ut coverage result:
Function Coverage: 36.74% (8654/23553)
Line Coverage: 28.76% (70685/245753)
Region Coverage: 27.65% (36458/131846)
Branch Coverage: 24.37% (18658/76562)
Coverage Report: http://coverage.selectdb-in.cc/coverage/12d3c90bae7e8f4bcd57bf5e2b25f72bbdcea38a_12d3c90bae7e8f4bcd57bf5e2b25f72bbdcea38a/report/index.html

@doris-robot

Copy link
Copy Markdown
TPC-DS: Total hot run time: 176423 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 12d3c90bae7e8f4bcd57bf5e2b25f72bbdcea38a, data reload: false

query1	937	335	337	335
query2	6551	1912	1901	1901
query3	6696	201	196	196
query4	33025	22295	22011	22011
query5	6846	609	591	591
query6	248	152	151	151
query7	4601	259	261	259
query8	232	178	175	175
query9	8419	2546	2520	2520
query10	427	229	226	226
query11	16732	15536	15466	15466
query12	125	70	67	67
query13	1684	372	365	365
query14	10575	7014	6893	6893
query15	211	170	175	170
query16	4593	235	222	222
query17	1002	464	462	462
query18	1807	257	253	253
query19	174	128	141	128
query20	69	76	67	67
query21	190	126	128	126
query22	4980	4787	4664	4664
query23	31555	30897	30889	30889
query24	12860	2822	2799	2799
query25	569	310	323	310
query26	1841	139	142	139
query27	3430	267	272	267
query28	7577	1840	1816	1816
query29	2160	628	611	611
query30	287	138	147	138
query31	946	737	776	737
query32	73	50	50	50
query33	718	208	214	208
query34	1332	453	459	453
query35	867	803	784	784
query36	1320	1217	1223	1217
query37	177	57	56	56
query38	3314	3208	3205	3205
query39	1338	1262	1270	1262
query40	345	83	81	81
query41	37	38	34	34
query42	90	83	83	83
query43	504	457	513	457
query44	1060	683	694	683
query45	203	186	176	176
query46	1069	651	643	643
query47	1678	1590	1595	1590
query48	398	302	309	302
query49	1218	289	276	276
query50	678	307	310	307
query51	5343	5160	5266	5160
query52	98	74	85	74
query53	329	250	252	250
query54	466	290	295	290
query55	79	81	78	78
query56	177	161	159	159
query57	995	958	953	953
query58	186	169	160	160
query59	2897	2686	2692	2686
query60	213	196	185	185
query61	82	85	83	83
query62	665	367	369	367
query63	280	262	257	257
query64	6105	1759	1746	1746
query65	3340	3265	3265	3265
query66	1423	324	324	324
query67	15790	15049	14959	14959
query68	13421	526	500	500
query69	583	312	296	296
query70	1846	1470	1503	1470
query71	475	205	210	205
query72	4742	2815	2830	2815
query73	3260	319	319	319
query74	7169	6258	6373	6258
query75	4859	2319	2331	2319
query76	6183	981	1006	981
query77	685	233	243	233
query78	9057	8758	8633	8633
query79	2006	503	491	491
query80	532	331	314	314
query81	448	207	205	205
query82	207	77	80	77
query83	138	119	121	119
query84	276	67	67	67
query85	1074	326	317	317
query86	401	378	363	363
query87	3555	3352	3355	3352
query88	2871	2207	2195	2195
query89	454	374	353	353
query90	1961	186	184	184
query91	155	121	131	121
query92	54	43	41	41
query93	1494	449	431	431
query94	1213	154	157	154
query95	490	470	450	450
query96	619	317	323	317
query97	4238	4160	4180	4160
query98	205	186	184	184
query99	1031	682	713	682
Total cold run time: 301938 ms
Total hot run time: 176423 ms

@doris-robot

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

query1	0.03	0.03	0.02
query2	0.06	0.02	0.02
query3	0.23	0.05	0.05
query4	1.67	0.07	0.08
query5	0.54	0.53	0.53
query6	1.31	0.62	0.64
query7	0.02	0.02	0.01
query8	0.04	0.02	0.03
query9	0.53	0.50	0.48
query10	0.56	0.55	0.54
query11	0.12	0.08	0.08
query12	0.11	0.10	0.09
query13	0.60	0.62	0.60
query14	0.79	0.79	0.79
query15	0.78	0.78	0.77
query16	0.40	0.39	0.39
query17	1.04	1.02	1.03
query18	0.24	0.26	0.26
query19	1.89	1.83	1.80
query20	0.01	0.01	0.01
query21	15.42	0.59	0.55
query22	2.67	2.54	1.90
query23	16.98	0.78	0.85
query24	2.86	1.28	0.77
query25	0.38	0.12	0.23
query26	0.62	0.14	0.13
query27	0.05	0.07	0.05
query28	11.41	0.80	0.78
query29	12.53	3.23	3.26
query30	0.56	0.49	0.48
query31	2.78	0.34	0.34
query32	3.37	0.47	0.48
query33	3.23	3.20	3.24
query34	15.98	4.30	4.24
query35	4.37	4.26	4.36
query36	1.11	1.08	1.07
query37	0.06	0.04	0.05
query38	0.04	0.03	0.03
query39	0.03	0.02	0.02
query40	0.16	0.16	0.14
query41	0.08	0.01	0.02
query42	0.03	0.02	0.02
query43	0.03	0.02	0.02
Total cold run time: 105.72 s
Total hot run time: 30.82 s

@doris-robot

Copy link
Copy Markdown

Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'

Load test result on commit 12d3c90bae7e8f4bcd57bf5e2b25f72bbdcea38a with default session variables
Stream load json:         19 seconds loaded 2358488459 Bytes, about 118 MB/s
Stream load orc:          59 seconds loaded 1101869774 Bytes, about 17 MB/s
Stream load parquet:      32 seconds loaded 861443392 Bytes, about 25 MB/s
Insert into select:       14.7 seconds inserted 10000000 Rows, about 680K ops/s

return Status::OK();

Status final_st = Status::OK();
if (source_state == SourceState::FINISHED) {

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.

If task stops early and never send with source_state == FINISH then channels will never close?

Comment thread be/src/pipeline/task_scheduler.cpp Outdated
: PipelineTaskState::FINISHED,
status);
// Only meet eos, should set task to PENDING_FINISH state
task->set_state(PipelineTaskState::PENDING_FINISH);

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.

Why always set PENDING_FINISH?

@yiguolei

Copy link
Copy Markdown
Contributor Author

run buildall

@doris-robot

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

------ Round 1 ----------------------------------
q1	17862	5493	5366	5366
q2	2395	144	150	144
q3	11220	1203	1202	1202
q4	10920	746	828	746
q5	7957	3259	3239	3239
q6	202	126	127	126
q7	896	507	498	498
q8	9331	1981	1984	1981
q9	7633	6388	6384	6384
q10	8203	3090	3053	3053
q11	413	215	207	207
q12	364	191	189	189
q13	17999	3373	3372	3372
q14	251	221	214	214
q15	560	515	496	496
q16	431	375	388	375
q17	976	561	513	513
q18	7759	7107	6964	6964
q19	1587	1427	1436	1427
q20	584	324	288	288
q21	2840	2443	2459	2443
q22	353	299	303	299
Total cold run time: 110736 ms
Total hot run time: 39526 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5405	5140	5119	5119
q2	330	217	208	208
q3	3324	3257	3264	3257
q4	2114	2088	2080	2080
q5	6107	5888	5972	5888
q6	204	116	120	116
q7	2325	1917	1904	1904
q8	3216	3390	3407	3390
q9	9049	9036	8840	8840
q10	4001	3839	3809	3809
q11	559	445	460	445
q12	829	643	631	631
q13	16893	3175	3197	3175
q14	287	256	268	256
q15	579	507	511	507
q16	520	490	467	467
q17	1868	1856	1819	1819
q18	9681	16698	9642	9642
q19	27339	1531	1495	1495
q20	4631	1927	1934	1927
q21	14515	5264	5233	5233
q22	1017	559	554	554
Total cold run time: 114793 ms
Total hot run time: 60762 ms

@doris-robot

Copy link
Copy Markdown
TPC-DS: Total hot run time: 176259 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 28b46397637c4885b1e3ba034187760ab4a7dcaa, data reload: false

query1	936	336	332	332
query2	6543	1893	1857	1857
query3	6697	198	196	196
query4	30639	22411	22207	22207
query5	4457	372	365	365
query6	246	154	152	152
query7	4615	262	260	260
query8	227	175	179	175
query9	8362	2524	2502	2502
query10	423	222	221	221
query11	16883	15559	15762	15559
query12	122	67	67	67
query13	1672	371	404	371
query14	10554	6973	6989	6973
query15	222	177	176	176
query16	5801	259	250	250
query17	942	475	477	475
query18	1779	253	258	253
query19	172	137	130	130
query20	71	64	70	64
query21	192	121	125	121
query22	4875	4726	4682	4682
query23	31786	30864	30873	30864
query24	12831	2840	2807	2807
query25	582	312	304	304
query26	1852	147	139	139
query27	3419	288	283	283
query28	7154	1826	1823	1823
query29	2170	635	629	629
query30	287	145	146	145
query31	946	746	749	746
query32	92	54	49	49
query33	712	210	213	210
query34	1265	458	479	458
query35	894	771	758	758
query36	1349	1163	1145	1145
query37	176	56	59	56
query38	3346	3249	3252	3249
query39	1316	1269	1285	1269
query40	341	87	86	86
query41	36	35	34	34
query42	92	81	81	81
query43	505	470	477	470
query44	1068	682	687	682
query45	189	181	173	173
query46	1055	663	654	654
query47	1637	1507	1569	1507
query48	395	311	328	311
query49	1220	290	287	287
query50	688	310	302	302
query51	5301	5192	5174	5174
query52	88	82	75	75
query53	336	249	264	249
query54	255	173	187	173
query55	87	77	70	70
query56	175	162	170	162
query57	1041	914	940	914
query58	193	164	160	160
query59	2849	2557	2672	2557
query60	210	190	181	181
query61	81	83	79	79
query62	608	364	375	364
query63	282	255	256	255
query64	6093	1812	1737	1737
query65	3326	3295	3247	3247
query66	1431	319	317	317
query67	15821	15427	15037	15037
query68	12540	511	509	509
query69	634	303	297	297
query70	1667	1518	1478	1478
query71	560	211	206	206
query72	4905	2875	2829	2829
query73	2793	312	313	312
query74	7028	6325	6354	6325
query75	5309	2337	2317	2317
query76	6749	1063	997	997
query77	797	233	236	233
query78	9394	8617	8683	8617
query79	1036	493	505	493
query80	576	319	311	311
query81	458	205	206	205
query82	201	79	80	79
query83	151	128	123	123
query84	278	68	69	68
query85	1109	333	328	328
query86	374	367	405	367
query87	3469	3319	3335	3319
query88	3054	2182	2171	2171
query89	431	368	358	358
query90	2000	186	182	182
query91	176	123	119	119
query92	56	43	44	43
query93	1344	458	414	414
query94	1261	156	156	156
query95	506	451	461	451
query96	618	313	312	312
query97	4245	4088	4131	4088
query98	203	192	191	191
query99	1053	701	704	701
Total cold run time: 296985 ms
Total hot run time: 176259 ms

@doris-robot

Copy link
Copy Markdown

TeamCity be ut coverage result:
Function Coverage: 36.73% (8657/23572)
Line Coverage: 28.76% (70699/245866)
Region Coverage: 27.63% (36447/131913)
Branch Coverage: 24.36% (18655/76590)
Coverage Report: http://coverage.selectdb-in.cc/coverage/28b46397637c4885b1e3ba034187760ab4a7dcaa_28b46397637c4885b1e3ba034187760ab4a7dcaa/report/index.html

@doris-robot

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

query1	0.03	0.03	0.03
query2	0.07	0.03	0.02
query3	0.23	0.05	0.05
query4	1.67	0.07	0.07
query5	0.53	0.52	0.52
query6	1.34	0.66	0.65
query7	0.02	0.02	0.01
query8	0.04	0.02	0.02
query9	0.55	0.50	0.50
query10	0.55	0.55	0.54
query11	0.11	0.08	0.08
query12	0.11	0.09	0.09
query13	0.61	0.62	0.61
query14	0.80	0.79	0.81
query15	0.81	0.79	0.78
query16	0.38	0.39	0.36
query17	1.05	1.02	1.01
query18	0.23	0.25	0.24
query19	1.90	1.80	1.78
query20	0.02	0.01	0.01
query21	15.42	0.57	0.56
query22	2.56	2.73	2.18
query23	17.69	0.74	0.78
query24	2.42	1.28	0.66
query25	0.38	0.17	0.14
query26	0.45	0.14	0.13
query27	0.07	0.04	0.06
query28	11.85	0.78	0.76
query29	12.52	3.12	3.18
query30	0.57	0.49	0.48
query31	2.78	0.33	0.35
query32	3.38	0.48	0.49
query33	3.20	3.27	3.23
query34	16.19	4.33	4.24
query35	4.29	4.27	4.24
query36	1.11	1.08	1.07
query37	0.07	0.05	0.05
query38	0.04	0.03	0.03
query39	0.03	0.02	0.01
query40	0.16	0.13	0.13
query41	0.07	0.01	0.02
query42	0.03	0.01	0.01
query43	0.02	0.02	0.02
Total cold run time: 106.35 s
Total hot run time: 30.82 s

@doris-robot

Copy link
Copy Markdown

Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'

Load test result on commit 28b46397637c4885b1e3ba034187760ab4a7dcaa with default session variables
Stream load json:         19 seconds loaded 2358488459 Bytes, about 118 MB/s
Stream load orc:          58 seconds loaded 1101869774 Bytes, about 18 MB/s
Stream load parquet:      33 seconds loaded 861443392 Bytes, about 24 MB/s
Insert into select:       14.1 seconds inserted 10000000 Rows, about 709K ops/s

@yiguolei

Copy link
Copy Markdown
Contributor Author

run buildall

@doris-robot

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

------ Round 1 ----------------------------------
q1	17637	5958	5397	5397
q2	2054	149	131	131
q3	10661	1158	1206	1158
q4	10228	795	801	795
q5	7774	3157	3169	3157
q6	200	121	120	120
q7	858	495	480	480
q8	9212	1935	1956	1935
q9	7285	6414	6340	6340
q10	8194	3026	3049	3026
q11	414	212	209	209
q12	363	195	192	192
q13	18004	3353	3364	3353
q14	239	218	224	218
q15	544	506	499	499
q16	426	376	373	373
q17	940	518	515	515
q18	7438	6998	6828	6828
q19	1607	1447	1351	1351
q20	604	320	283	283
q21	2857	2426	2388	2388
q22	355	300	309	300
Total cold run time: 107894 ms
Total hot run time: 39048 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5368	5259	5463	5259
q2	340	215	208	208
q3	3335	3263	3221	3221
q4	2066	2045	2028	2028
q5	5959	5921	5961	5921
q6	196	116	118	116
q7	2260	1939	1899	1899
q8	3210	3381	3377	3377
q9	9006	9044	9666	9044
q10	3893	3872	3803	3803
q11	557	458	454	454
q12	817	644	609	609
q13	16919	3130	3152	3130
q14	296	264	266	264
q15	541	511	510	510
q16	527	472	481	472
q17	1915	1817	1871	1817
q18	9648	18046	9663	9663
q19	26234	1551	1496	1496
q20	4557	1928	1914	1914
q21	14424	5353	5252	5252
q22	985	530	527	527
Total cold run time: 113053 ms
Total hot run time: 60984 ms

@doris-robot

Copy link
Copy Markdown

TeamCity be ut coverage result:
Function Coverage: 36.72% (8663/23594)
Line Coverage: 28.74% (70735/246106)
Region Coverage: 27.62% (36461/131988)
Branch Coverage: 24.36% (18662/76612)
Coverage Report: http://coverage.selectdb-in.cc/coverage/a83c8599b7fd56c7e8634d409a1acf61197f994f_a83c8599b7fd56c7e8634d409a1acf61197f994f/report/index.html

@doris-robot

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

query1	1057	343	343	343
query2	7019	1991	1941	1941
query3	6703	208	197	197
query4	30491	22192	22121	22121
query5	4452	377	444	377
query6	242	158	152	152
query7	4601	275	261	261
query8	236	172	176	172
query9	8313	2557	2555	2555
query10	432	243	244	243
query11	16694	15631	15663	15631
query12	130	68	65	65
query13	1682	375	378	375
query14	10550	7036	7054	7036
query15	218	177	182	177
query16	5785	254	255	254
query17	941	479	482	479
query18	1797	261	251	251
query19	181	134	141	134
query20	72	72	67	67
query21	192	130	132	130
query22	4989	4726	4791	4726
query23	31566	30865	30959	30865
query24	12611	2838	2765	2765
query25	561	310	307	307
query26	1793	150	145	145
query27	3210	293	287	287
query28	7245	1838	1837	1837
query29	2062	629	638	629
query30	282	135	138	135
query31	955	744	753	744
query32	75	52	49	49
query33	708	222	218	218
query34	1158	456	474	456
query35	844	749	776	749
query36	1355	1243	1225	1225
query37	102	56	57	56
query38	3380	3268	3200	3200
query39	1355	1269	1270	1269
query40	344	86	86	86
query41	38	35	34	34
query42	98	86	91	86
query43	480	488	490	488
query44	1132	692	688	688
query45	197	177	177	177
query46	1080	661	647	647
query47	1667	1615	1522	1522
query48	382	319	310	310
query49	1219	297	294	294
query50	682	319	320	319
query51	5287	5225	5202	5202
query52	92	78	73	73
query53	324	257	255	255
query54	240	187	185	185
query55	82	76	76	76
query56	187	170	175	170
query57	992	958	956	956
query58	191	155	165	155
query59	2864	2751	2753	2751
query60	211	186	193	186
query61	85	83	84	83
query62	637	353	358	353
query63	278	256	259	256
query64	6345	1792	1770	1770
query65	3344	3295	3235	3235
query66	1406	319	340	319
query67	15650	15009	15108	15009
query68	10460	528	524	524
query69	582	296	297	296
query70	1638	1488	1502	1488
query71	526	222	217	217
query72	4681	2814	2827	2814
query73	1923	309	308	308
query74	7050	6298	6350	6298
query75	4634	2352	2338	2338
query76	6672	977	1019	977
query77	639	233	243	233
query78	9112	8768	8486	8486
query79	2137	499	522	499
query80	621	330	322	322
query81	446	203	201	201
query82	212	82	80	80
query83	137	117	126	117
query84	278	68	74	68
query85	1094	375	332	332
query86	399	406	405	405
query87	3478	3349	3341	3341
query88	3646	2197	2191	2191
query89	466	358	343	343
query90	2008	193	191	191
query91	159	129	124	124
query92	54	44	46	44
query93	3615	456	450	450
query94	1224	160	160	160
query95	505	480	456	456
query96	622	322	320	320
query97	4273	4148	4174	4148
query98	198	194	177	177
query99	1089	692	704	692
Total cold run time: 296151 ms
Total hot run time: 176948 ms

@doris-robot

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

query1	0.03	0.02	0.02
query2	0.06	0.02	0.02
query3	0.23	0.07	0.06
query4	1.67	0.09	0.08
query5	0.52	0.52	0.52
query6	1.33	0.61	0.63
query7	0.02	0.01	0.02
query8	0.04	0.02	0.02
query9	0.52	0.48	0.49
query10	0.55	0.56	0.56
query11	0.12	0.09	0.09
query12	0.11	0.10	0.09
query13	0.60	0.61	0.60
query14	0.77	0.81	0.81
query15	0.79	0.77	0.78
query16	0.39	0.39	0.38
query17	1.00	1.02	1.01
query18	0.24	0.25	0.26
query19	1.89	1.84	1.72
query20	0.01	0.01	0.01
query21	15.40	0.57	0.58
query22	2.63	2.66	2.26
query23	17.26	0.90	0.82
query24	2.40	0.88	0.83
query25	0.46	0.13	0.14
query26	0.51	0.13	0.14
query27	0.07	0.06	0.05
query28	11.79	0.76	0.77
query29	12.53	3.25	3.17
query30	0.63	0.49	0.49
query31	2.78	0.34	0.34
query32	3.39	0.49	0.49
query33	3.26	3.21	3.25
query34	16.05	4.25	4.25
query35	4.33	4.25	4.26
query36	1.14	1.07	1.08
query37	0.06	0.04	0.05
query38	0.03	0.03	0.02
query39	0.02	0.02	0.01
query40	0.16	0.13	0.13
query41	0.08	0.01	0.01
query42	0.02	0.02	0.01
query43	0.02	0.02	0.02
Total cold run time: 105.91 s
Total hot run time: 31.17 s

@doris-robot

Copy link
Copy Markdown

Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'

Load test result on commit a83c8599b7fd56c7e8634d409a1acf61197f994f with default session variables
Stream load json:         19 seconds loaded 2358488459 Bytes, about 118 MB/s
Stream load orc:          59 seconds loaded 1101869774 Bytes, about 17 MB/s
Stream load parquet:      31 seconds loaded 861443392 Bytes, about 26 MB/s
Insert into select:       14.8 seconds inserted 10000000 Rows, about 675K ops/s

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@yiguolei

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions github-actions Bot removed the approved Indicates a PR has been approved by one committer. label Jan 23, 2024
@doris-robot

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

------ Round 1 ----------------------------------
q1	17597	5437	5780	5437
q2	2040	138	132	132
q3	10820	1173	1175	1173
q4	10842	815	810	810
q5	8306	3304	3217	3217
q6	203	127	126	126
q7	882	518	495	495
q8	9444	1948	1980	1948
q9	7926	6542	6481	6481
q10	8226	3061	3075	3061
q11	408	205	217	205
q12	357	188	192	188
q13	17980	3388	3366	3366
q14	242	213	220	213
q15	536	516	510	510
q16	433	369	375	369
q17	941	558	531	531
q18	7833	7149	6863	6863
q19	1598	1384	1402	1384
q20	583	300	323	300
q21	2820	2438	2438	2438
q22	361	319	318	318
Total cold run time: 110378 ms
Total hot run time: 39565 ms

----- Round 2, with runtime_filter_mode=off -----
q1	5409	5320	5176	5176
q2	322	217	208	208
q3	3335	3268	3242	3242
q4	2061	2087	2035	2035
q5	6129	5828	5939	5828
q6	194	118	118	118
q7	2289	1818	1923	1818
q8	3240	3413	3420	3413
q9	8986	9014	11643	9014
q10	3915	3869	3886	3869
q11	550	452	460	452
q12	787	616	616	616
q13	16917	3196	3156	3156
q14	287	261	262	261
q15	558	512	511	511
q16	530	467	459	459
q17	1860	1844	1815	1815
q18	9694	17428	9865	9865
q19	26657	1636	1557	1557
q20	4564	1948	1934	1934
q21	14432	5293	5443	5293
q22	971	577	576	576
Total cold run time: 113687 ms
Total hot run time: 61216 ms

@doris-robot

Copy link
Copy Markdown
TPC-DS: Total hot run time: 176418 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 33c4e1ffd6a2ff0ea02c51330097ed3c4c30c160, data reload: false

query1	921	328	325	325
query2	6566	2035	1915	1915
query3	6728	199	200	199
query4	31250	22055	22219	22055
query5	4449	447	442	442
query6	239	158	157	157
query7	4603	259	260	259
query8	237	171	181	171
query9	8439	2522	2510	2510
query10	430	222	242	222
query11	16628	15625	15544	15544
query12	117	69	66	66
query13	1677	380	375	375
query14	10621	6920	6899	6899
query15	214	184	186	184
query16	5788	249	252	249
query17	951	470	469	469
query18	1776	255	257	255
query19	173	134	132	132
query20	72	72	68	68
query21	191	138	123	123
query22	4933	4731	4784	4731
query23	31490	30785	30682	30682
query24	12574	2854	2796	2796
query25	573	303	309	303
query26	1752	151	144	144
query27	3227	284	283	283
query28	7168	1842	1821	1821
query29	1806	621	623	621
query30	282	137	142	137
query31	966	750	765	750
query32	83	52	47	47
query33	705	210	210	210
query34	1131	463	472	463
query35	892	767	772	767
query36	1330	1216	1228	1216
query37	91	59	60	59
query38	3381	3238	3234	3234
query39	1310	1261	1260	1260
query40	340	84	85	84
query41	35	35	33	33
query42	83	79	76	76
query43	526	447	490	447
query44	1066	680	675	675
query45	196	174	178	174
query46	1078	649	656	649
query47	1595	1495	1587	1495
query48	393	303	323	303
query49	1168	281	283	281
query50	683	321	305	305
query51	5220	5243	5226	5226
query52	81	89	77	77
query53	313	274	255	255
query54	237	181	177	177
query55	83	77	75	75
query56	177	181	176	176
query57	1042	939	934	934
query58	191	157	162	157
query59	3015	2736	2765	2736
query60	214	181	191	181
query61	83	82	82	82
query62	634	379	346	346
query63	276	252	260	252
query64	6112	1802	1759	1759
query65	3346	3273	3246	3246
query66	1271	328	305	305
query67	15625	15273	15246	15246
query68	13217	545	501	501
query69	587	289	300	289
query70	1790	1556	1490	1490
query71	481	209	215	209
query72	4823	2810	2802	2802
query73	3370	311	313	311
query74	6951	6383	6578	6383
query75	4927	2350	2270	2270
query76	6250	1041	985	985
query77	693	241	234	234
query78	9421	8977	8513	8513
query79	1128	494	501	494
query80	557	327	312	312
query81	455	212	206	206
query82	199	83	75	75
query83	138	115	126	115
query84	278	66	67	66
query85	1047	326	339	326
query86	393	374	368	368
query87	3561	3361	3336	3336
query88	2805	2187	2192	2187
query89	419	354	368	354
query90	1948	187	181	181
query91	152	129	136	129
query92	51	46	45	45
query93	1361	466	420	420
query94	1220	155	154	154
query95	499	454	453	453
query96	604	314	317	314
query97	4268	4139	4143	4139
query98	206	192	185	185
query99	1051	677	711	677
Total cold run time: 295697 ms
Total hot run time: 176418 ms

@doris-robot

Copy link
Copy Markdown

TeamCity be ut coverage result:
Function Coverage: 36.71% (8665/23607)
Line Coverage: 28.72% (70735/246288)
Region Coverage: 27.60% (36451/132062)
Branch Coverage: 24.34% (18660/76664)
Coverage Report: http://coverage.selectdb-in.cc/coverage/33c4e1ffd6a2ff0ea02c51330097ed3c4c30c160_33c4e1ffd6a2ff0ea02c51330097ed3c4c30c160/report/index.html

@doris-robot

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

query1	0.03	0.02	0.02
query2	0.05	0.02	0.02
query3	0.23	0.04	0.04
query4	1.71	0.07	0.08
query5	0.54	0.52	0.54
query6	1.29	0.62	0.63
query7	0.02	0.01	0.02
query8	0.04	0.02	0.02
query9	0.55	0.51	0.50
query10	0.56	0.54	0.55
query11	0.11	0.08	0.08
query12	0.10	0.10	0.08
query13	0.60	0.61	0.60
query14	0.78	0.80	0.79
query15	0.80	0.78	0.77
query16	0.37	0.37	0.38
query17	1.00	1.02	1.00
query18	0.24	0.24	0.25
query19	1.84	1.80	1.75
query20	0.01	0.00	0.01
query21	15.42	0.56	0.56
query22	2.66	2.36	2.32
query23	17.30	0.81	0.81
query24	2.68	1.21	0.49
query25	0.38	0.26	0.19
query26	0.47	0.13	0.14
query27	0.07	0.05	0.05
query28	11.67	0.76	0.76
query29	12.54	3.52	3.52
query30	0.53	0.54	0.48
query31	2.79	0.34	0.34
query32	3.39	0.48	0.49
query33	3.21	3.24	3.21
query34	15.82	4.34	4.29
query35	4.32	4.35	4.31
query36	1.12	1.08	1.07
query37	0.07	0.05	0.05
query38	0.04	0.03	0.03
query39	0.02	0.01	0.02
query40	0.16	0.13	0.13
query41	0.07	0.02	0.01
query42	0.02	0.02	0.01
query43	0.02	0.02	0.01
Total cold run time: 105.64 s
Total hot run time: 31.3 s

@doris-robot

Copy link
Copy Markdown

Load test result on machine: 'aliyun_ecs.c7a.8xlarge_32C64G'

Load test result on commit 33c4e1ffd6a2ff0ea02c51330097ed3c4c30c160 with default session variables
Stream load json:         19 seconds loaded 2358488459 Bytes, about 118 MB/s
Stream load orc:          58 seconds loaded 1101869774 Bytes, about 18 MB/s
Stream load parquet:      31 seconds loaded 861443392 Bytes, about 26 MB/s
Insert into select:       14.9 seconds inserted 10000000 Rows, about 671K ops/s

RETURN_IF_ERROR(_writer->get_writer_status());
Status st = _writer->get_writer_status();
if (exec_status.ok()) {
_writer->force_close(state->is_cancelled() ? Status::Cancelled("Cancelled")

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.

which case the cancel the writer for force close

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

LGTM

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Jan 23, 2024

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

LGTM

@yiguolei
yiguolei merged commit 7037abc into apache:master Jan 23, 2024
yiguolei added a commit that referenced this pull request Jan 23, 2024

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

LGTM

zhangstar333 pushed a commit that referenced this pull request Sep 29, 2025
### What problem does this PR solve?

Related PR: #30082

Problem Summary:

We are using doris 3.0.4 with java udf, when running long time, some BE
may got jvm deadlocks with UNKNOWN_owner_addr
[deadlock in udf close]
<img width="2314" height="882" alt="image"
src="https://github.com/user-attachments/assets/c16b5d18-9900-45dc-8bb4-894180694a44"
/>
[deadlock in throwableToStackTrace, waiting a StringWriter , but this is
impossible , because StringWriter was newed everytime]
<img width="1724" height="720" alt="image"
src="https://github.com/user-attachments/assets/b586f752-0ba8-43cc-89b4-352a7d9ab00c"
/>
<img width="618" height="144" alt="image"
src="https://github.com/user-attachments/assets/20c2ad11-beef-4b0c-b2a2-343d9b0fd14c"
/>


In be.WARNING we found  get JNIEnv failed when close udf
<img width="1659" height="426" alt="image"
src="https://github.com/user-attachments/assets/6cf54aa2-522a-407e-a53a-e17fdbc9162e"
/>
In be.out we found libhdfs error log [JNIEnv is got by libhdfs when in
X86 ]
Call to AttachCurrentThread failed with error: -1
getJNIEnv: getGlobalJNIEnv failed

In be.WARNING there are some other err  when using GetJniExceptionMsg
<img width="1686" height="530" alt="image"
src="https://github.com/user-attachments/assets/35ca7b4c-0a9d-4da3-8be2-9a07ccebb74b"
/>

we found all those err has common ground
1.all case occured  in JavaFunctionCall::close
2.the stack all have bthread keyword

after seaching the web , we found that JNI is not compatible with
bthread
https://blog.csdn.net/qq_46104835/article/details/139360911

https://gitee.com/baidu/BRPC/blob/master/docs/cn/server.md#pthread%E6%A8%A1%E5%BC%8F
<img width="1101" height="211" alt="image"
src="https://github.com/user-attachments/assets/e1da2f9a-9e37-47d9-b0a1-c1652da93e75"
/>

the bthread stack layout is not compatible for java, so we may meed
1. AttachCurrentThread[using by getJNIEnv] will check stack layout fail
2. AttachCurrentThread/getJNIEnv may success, but java method may
execute failed, even deadlock, because the stack layout has incompatible
address for jvm


Then we switch bthread to pthread mode , every thing works fine.[add
-usercode_in_pthread=true]

We want to know how often bhread do the JavaFunctionCall::close, then we
add metrics. only 1/10000 JavaFunctionCall::close running in bthread
<img width="1886" height="358" alt="image"
src="https://github.com/user-attachments/assets/34293bac-696b-41f9-b5eb-4daaab81fb7f"
/>

But why JavaFunctionCall::close occured in bthread[ after
#16634, exec_plan_fragment is
running in pthread instead of bthread]

then we found a pr
#30082

ExchangeSinkBuffer<Parent>::_send_rpc will set a send_callback with a
weak_task_ctx
<img width="1392" height="254" alt="image"
src="https://github.com/user-attachments/assets/a1d28f18-c3c7-4953-baab-d1109f341aa1"
/>
So sometimes send_callback may using weak_task_ctx.lock() to get a
shared_ptr to task_ctx, then task_ctx destructor my be called in
send_callback[ send_callback is running in bthread]

So We modify JavaFunctionCall::close
when JavaFunctionCall::close running in bthread, we submit the jni
operation to a pthread pool, and wait it finish
because only 1/10000 JavaFunctionCall::close are running in bthread. the
pthread pool size can set to a small number.
github-actions Bot pushed a commit that referenced this pull request Nov 12, 2025
### What problem does this PR solve?

Related PR: #30082

Problem Summary:

We are using doris 3.0.4 with java udf, when running long time, some BE
may got jvm deadlocks with UNKNOWN_owner_addr
[deadlock in udf close]
<img width="2314" height="882" alt="image"
src="https://github.com/user-attachments/assets/c16b5d18-9900-45dc-8bb4-894180694a44"
/>
[deadlock in throwableToStackTrace, waiting a StringWriter , but this is
impossible , because StringWriter was newed everytime]
<img width="1724" height="720" alt="image"
src="https://github.com/user-attachments/assets/b586f752-0ba8-43cc-89b4-352a7d9ab00c"
/>
<img width="618" height="144" alt="image"
src="https://github.com/user-attachments/assets/20c2ad11-beef-4b0c-b2a2-343d9b0fd14c"
/>


In be.WARNING we found  get JNIEnv failed when close udf
<img width="1659" height="426" alt="image"
src="https://github.com/user-attachments/assets/6cf54aa2-522a-407e-a53a-e17fdbc9162e"
/>
In be.out we found libhdfs error log [JNIEnv is got by libhdfs when in
X86 ]
Call to AttachCurrentThread failed with error: -1
getJNIEnv: getGlobalJNIEnv failed

In be.WARNING there are some other err  when using GetJniExceptionMsg
<img width="1686" height="530" alt="image"
src="https://github.com/user-attachments/assets/35ca7b4c-0a9d-4da3-8be2-9a07ccebb74b"
/>

we found all those err has common ground
1.all case occured  in JavaFunctionCall::close
2.the stack all have bthread keyword

after seaching the web , we found that JNI is not compatible with
bthread
https://blog.csdn.net/qq_46104835/article/details/139360911

https://gitee.com/baidu/BRPC/blob/master/docs/cn/server.md#pthread%E6%A8%A1%E5%BC%8F
<img width="1101" height="211" alt="image"
src="https://github.com/user-attachments/assets/e1da2f9a-9e37-47d9-b0a1-c1652da93e75"
/>

the bthread stack layout is not compatible for java, so we may meed
1. AttachCurrentThread[using by getJNIEnv] will check stack layout fail
2. AttachCurrentThread/getJNIEnv may success, but java method may
execute failed, even deadlock, because the stack layout has incompatible
address for jvm


Then we switch bthread to pthread mode , every thing works fine.[add
-usercode_in_pthread=true]

We want to know how often bhread do the JavaFunctionCall::close, then we
add metrics. only 1/10000 JavaFunctionCall::close running in bthread
<img width="1886" height="358" alt="image"
src="https://github.com/user-attachments/assets/34293bac-696b-41f9-b5eb-4daaab81fb7f"
/>

But why JavaFunctionCall::close occured in bthread[ after
#16634, exec_plan_fragment is
running in pthread instead of bthread]

then we found a pr
#30082

ExchangeSinkBuffer<Parent>::_send_rpc will set a send_callback with a
weak_task_ctx
<img width="1392" height="254" alt="image"
src="https://github.com/user-attachments/assets/a1d28f18-c3c7-4953-baab-d1109f341aa1"
/>
So sometimes send_callback may using weak_task_ctx.lock() to get a
shared_ptr to task_ctx, then task_ctx destructor my be called in
send_callback[ send_callback is running in bthread]

So We modify JavaFunctionCall::close
when JavaFunctionCall::close running in bthread, we submit the jni
operation to a pthread pool, and wait it finish
because only 1/10000 JavaFunctionCall::close are running in bthread. the
pthread pool size can set to a small number.
zclllyybb pushed a commit to zclllyybb/doris that referenced this pull request Feb 28, 2026
…#55302)

### What problem does this PR solve?

Related PR: apache#30082

Problem Summary:

We are using doris 3.0.4 with java udf, when running long time, some BE
may got jvm deadlocks with UNKNOWN_owner_addr
[deadlock in udf close]
<img width="2314" height="882" alt="image"
src="https://github.com/user-attachments/assets/c16b5d18-9900-45dc-8bb4-894180694a44"
/>
[deadlock in throwableToStackTrace, waiting a StringWriter , but this is
impossible , because StringWriter was newed everytime]
<img width="1724" height="720" alt="image"
src="https://github.com/user-attachments/assets/b586f752-0ba8-43cc-89b4-352a7d9ab00c"
/>
<img width="618" height="144" alt="image"
src="https://github.com/user-attachments/assets/20c2ad11-beef-4b0c-b2a2-343d9b0fd14c"
/>


In be.WARNING we found  get JNIEnv failed when close udf
<img width="1659" height="426" alt="image"
src="https://github.com/user-attachments/assets/6cf54aa2-522a-407e-a53a-e17fdbc9162e"
/>
In be.out we found libhdfs error log [JNIEnv is got by libhdfs when in
X86 ]
Call to AttachCurrentThread failed with error: -1
getJNIEnv: getGlobalJNIEnv failed

In be.WARNING there are some other err  when using GetJniExceptionMsg
<img width="1686" height="530" alt="image"
src="https://github.com/user-attachments/assets/35ca7b4c-0a9d-4da3-8be2-9a07ccebb74b"
/>

we found all those err has common ground
1.all case occured  in JavaFunctionCall::close
2.the stack all have bthread keyword

after seaching the web , we found that JNI is not compatible with
bthread
https://blog.csdn.net/qq_46104835/article/details/139360911

https://gitee.com/baidu/BRPC/blob/master/docs/cn/server.md#pthread%E6%A8%A1%E5%BC%8F
<img width="1101" height="211" alt="image"
src="https://github.com/user-attachments/assets/e1da2f9a-9e37-47d9-b0a1-c1652da93e75"
/>

the bthread stack layout is not compatible for java, so we may meed
1. AttachCurrentThread[using by getJNIEnv] will check stack layout fail
2. AttachCurrentThread/getJNIEnv may success, but java method may
execute failed, even deadlock, because the stack layout has incompatible
address for jvm


Then we switch bthread to pthread mode , every thing works fine.[add
-usercode_in_pthread=true]

We want to know how often bhread do the JavaFunctionCall::close, then we
add metrics. only 1/10000 JavaFunctionCall::close running in bthread
<img width="1886" height="358" alt="image"
src="https://github.com/user-attachments/assets/34293bac-696b-41f9-b5eb-4daaab81fb7f"
/>

But why JavaFunctionCall::close occured in bthread[ after
apache#16634, exec_plan_fragment is
running in pthread instead of bthread]

then we found a pr
apache#30082

ExchangeSinkBuffer<Parent>::_send_rpc will set a send_callback with a
weak_task_ctx
<img width="1392" height="254" alt="image"
src="https://github.com/user-attachments/assets/a1d28f18-c3c7-4953-baab-d1109f341aa1"
/>
So sometimes send_callback may using weak_task_ctx.lock() to get a
shared_ptr to task_ctx, then task_ctx destructor my be called in
send_callback[ send_callback is running in bthread]

So We modify JavaFunctionCall::close
when JavaFunctionCall::close running in bthread, we submit the jni
operation to a pthread pool, and wait it finish
because only 1/10000 JavaFunctionCall::close are running in bthread. the
pthread pool size can set to a small number.
zclllyybb pushed a commit to zclllyybb/doris that referenced this pull request Mar 1, 2026
…#55302)

### What problem does this PR solve?

Related PR: apache#30082

Problem Summary:

We are using doris 3.0.4 with java udf, when running long time, some BE
may got jvm deadlocks with UNKNOWN_owner_addr
[deadlock in udf close]
<img width="2314" height="882" alt="image"
src="https://github.com/user-attachments/assets/c16b5d18-9900-45dc-8bb4-894180694a44"
/>
[deadlock in throwableToStackTrace, waiting a StringWriter , but this is
impossible , because StringWriter was newed everytime]
<img width="1724" height="720" alt="image"
src="https://github.com/user-attachments/assets/b586f752-0ba8-43cc-89b4-352a7d9ab00c"
/>
<img width="618" height="144" alt="image"
src="https://github.com/user-attachments/assets/20c2ad11-beef-4b0c-b2a2-343d9b0fd14c"
/>


In be.WARNING we found  get JNIEnv failed when close udf
<img width="1659" height="426" alt="image"
src="https://github.com/user-attachments/assets/6cf54aa2-522a-407e-a53a-e17fdbc9162e"
/>
In be.out we found libhdfs error log [JNIEnv is got by libhdfs when in
X86 ]
Call to AttachCurrentThread failed with error: -1
getJNIEnv: getGlobalJNIEnv failed

In be.WARNING there are some other err  when using GetJniExceptionMsg
<img width="1686" height="530" alt="image"
src="https://github.com/user-attachments/assets/35ca7b4c-0a9d-4da3-8be2-9a07ccebb74b"
/>

we found all those err has common ground
1.all case occured  in JavaFunctionCall::close
2.the stack all have bthread keyword

after seaching the web , we found that JNI is not compatible with
bthread
https://blog.csdn.net/qq_46104835/article/details/139360911

https://gitee.com/baidu/BRPC/blob/master/docs/cn/server.md#pthread%E6%A8%A1%E5%BC%8F
<img width="1101" height="211" alt="image"
src="https://github.com/user-attachments/assets/e1da2f9a-9e37-47d9-b0a1-c1652da93e75"
/>

the bthread stack layout is not compatible for java, so we may meed
1. AttachCurrentThread[using by getJNIEnv] will check stack layout fail
2. AttachCurrentThread/getJNIEnv may success, but java method may
execute failed, even deadlock, because the stack layout has incompatible
address for jvm


Then we switch bthread to pthread mode , every thing works fine.[add
-usercode_in_pthread=true]

We want to know how often bhread do the JavaFunctionCall::close, then we
add metrics. only 1/10000 JavaFunctionCall::close running in bthread
<img width="1886" height="358" alt="image"
src="https://github.com/user-attachments/assets/34293bac-696b-41f9-b5eb-4daaab81fb7f"
/>

But why JavaFunctionCall::close occured in bthread[ after
apache#16634, exec_plan_fragment is
running in pthread instead of bthread]

then we found a pr
apache#30082

ExchangeSinkBuffer<Parent>::_send_rpc will set a send_callback with a
weak_task_ctx
<img width="1392" height="254" alt="image"
src="https://github.com/user-attachments/assets/a1d28f18-c3c7-4953-baab-d1109f341aa1"
/>
So sometimes send_callback may using weak_task_ctx.lock() to get a
shared_ptr to task_ctx, then task_ctx destructor my be called in
send_callback[ send_callback is running in bthread]

So We modify JavaFunctionCall::close
when JavaFunctionCall::close running in bthread, we submit the jni
operation to a pthread pool, and wait it finish
because only 1/10000 JavaFunctionCall::close are running in bthread. the
pthread pool size can set to a small number.
zclllyybb pushed a commit to zclllyybb/doris that referenced this pull request Mar 1, 2026
…#55302)

### What problem does this PR solve?

Related PR: apache#30082

Problem Summary:

We are using doris 3.0.4 with java udf, when running long time, some BE
may got jvm deadlocks with UNKNOWN_owner_addr
[deadlock in udf close]
<img width="2314" height="882" alt="image"
src="https://github.com/user-attachments/assets/c16b5d18-9900-45dc-8bb4-894180694a44"
/>
[deadlock in throwableToStackTrace, waiting a StringWriter , but this is
impossible , because StringWriter was newed everytime]
<img width="1724" height="720" alt="image"
src="https://github.com/user-attachments/assets/b586f752-0ba8-43cc-89b4-352a7d9ab00c"
/>
<img width="618" height="144" alt="image"
src="https://github.com/user-attachments/assets/20c2ad11-beef-4b0c-b2a2-343d9b0fd14c"
/>


In be.WARNING we found  get JNIEnv failed when close udf
<img width="1659" height="426" alt="image"
src="https://github.com/user-attachments/assets/6cf54aa2-522a-407e-a53a-e17fdbc9162e"
/>
In be.out we found libhdfs error log [JNIEnv is got by libhdfs when in
X86 ]
Call to AttachCurrentThread failed with error: -1
getJNIEnv: getGlobalJNIEnv failed

In be.WARNING there are some other err  when using GetJniExceptionMsg
<img width="1686" height="530" alt="image"
src="https://github.com/user-attachments/assets/35ca7b4c-0a9d-4da3-8be2-9a07ccebb74b"
/>

we found all those err has common ground
1.all case occured  in JavaFunctionCall::close
2.the stack all have bthread keyword

after seaching the web , we found that JNI is not compatible with
bthread
https://blog.csdn.net/qq_46104835/article/details/139360911

https://gitee.com/baidu/BRPC/blob/master/docs/cn/server.md#pthread%E6%A8%A1%E5%BC%8F
<img width="1101" height="211" alt="image"
src="https://github.com/user-attachments/assets/e1da2f9a-9e37-47d9-b0a1-c1652da93e75"
/>

the bthread stack layout is not compatible for java, so we may meed
1. AttachCurrentThread[using by getJNIEnv] will check stack layout fail
2. AttachCurrentThread/getJNIEnv may success, but java method may
execute failed, even deadlock, because the stack layout has incompatible
address for jvm


Then we switch bthread to pthread mode , every thing works fine.[add
-usercode_in_pthread=true]

We want to know how often bhread do the JavaFunctionCall::close, then we
add metrics. only 1/10000 JavaFunctionCall::close running in bthread
<img width="1886" height="358" alt="image"
src="https://github.com/user-attachments/assets/34293bac-696b-41f9-b5eb-4daaab81fb7f"
/>

But why JavaFunctionCall::close occured in bthread[ after
apache#16634, exec_plan_fragment is
running in pthread instead of bthread]

then we found a pr
apache#30082

ExchangeSinkBuffer<Parent>::_send_rpc will set a send_callback with a
weak_task_ctx
<img width="1392" height="254" alt="image"
src="https://github.com/user-attachments/assets/a1d28f18-c3c7-4953-baab-d1109f341aa1"
/>
So sometimes send_callback may using weak_task_ctx.lock() to get a
shared_ptr to task_ctx, then task_ctx destructor my be called in
send_callback[ send_callback is running in bthread]

So We modify JavaFunctionCall::close
when JavaFunctionCall::close running in bthread, we submit the jni
operation to a pthread pool, and wait it finish
because only 1/10000 JavaFunctionCall::close are running in bthread. the
pthread pool size can set to a small number.
zclllyybb pushed a commit to zclllyybb/doris that referenced this pull request Mar 1, 2026
…#55302)

### What problem does this PR solve?

Related PR: apache#30082

Problem Summary:

We are using doris 3.0.4 with java udf, when running long time, some BE
may got jvm deadlocks with UNKNOWN_owner_addr
[deadlock in udf close]
<img width="2314" height="882" alt="image"
src="https://github.com/user-attachments/assets/c16b5d18-9900-45dc-8bb4-894180694a44"
/>
[deadlock in throwableToStackTrace, waiting a StringWriter , but this is
impossible , because StringWriter was newed everytime]
<img width="1724" height="720" alt="image"
src="https://github.com/user-attachments/assets/b586f752-0ba8-43cc-89b4-352a7d9ab00c"
/>
<img width="618" height="144" alt="image"
src="https://github.com/user-attachments/assets/20c2ad11-beef-4b0c-b2a2-343d9b0fd14c"
/>


In be.WARNING we found  get JNIEnv failed when close udf
<img width="1659" height="426" alt="image"
src="https://github.com/user-attachments/assets/6cf54aa2-522a-407e-a53a-e17fdbc9162e"
/>
In be.out we found libhdfs error log [JNIEnv is got by libhdfs when in
X86 ]
Call to AttachCurrentThread failed with error: -1
getJNIEnv: getGlobalJNIEnv failed

In be.WARNING there are some other err  when using GetJniExceptionMsg
<img width="1686" height="530" alt="image"
src="https://github.com/user-attachments/assets/35ca7b4c-0a9d-4da3-8be2-9a07ccebb74b"
/>

we found all those err has common ground
1.all case occured  in JavaFunctionCall::close
2.the stack all have bthread keyword

after seaching the web , we found that JNI is not compatible with
bthread
https://blog.csdn.net/qq_46104835/article/details/139360911

https://gitee.com/baidu/BRPC/blob/master/docs/cn/server.md#pthread%E6%A8%A1%E5%BC%8F
<img width="1101" height="211" alt="image"
src="https://github.com/user-attachments/assets/e1da2f9a-9e37-47d9-b0a1-c1652da93e75"
/>

the bthread stack layout is not compatible for java, so we may meed
1. AttachCurrentThread[using by getJNIEnv] will check stack layout fail
2. AttachCurrentThread/getJNIEnv may success, but java method may
execute failed, even deadlock, because the stack layout has incompatible
address for jvm


Then we switch bthread to pthread mode , every thing works fine.[add
-usercode_in_pthread=true]

We want to know how often bhread do the JavaFunctionCall::close, then we
add metrics. only 1/10000 JavaFunctionCall::close running in bthread
<img width="1886" height="358" alt="image"
src="https://github.com/user-attachments/assets/34293bac-696b-41f9-b5eb-4daaab81fb7f"
/>

But why JavaFunctionCall::close occured in bthread[ after
apache#16634, exec_plan_fragment is
running in pthread instead of bthread]

then we found a pr
apache#30082

ExchangeSinkBuffer<Parent>::_send_rpc will set a send_callback with a
weak_task_ctx
<img width="1392" height="254" alt="image"
src="https://github.com/user-attachments/assets/a1d28f18-c3c7-4953-baab-d1109f341aa1"
/>
So sometimes send_callback may using weak_task_ctx.lock() to get a
shared_ptr to task_ctx, then task_ctx destructor my be called in
send_callback[ send_callback is running in bthread]

So We modify JavaFunctionCall::close
when JavaFunctionCall::close running in bthread, we submit the jni
operation to a pthread pool, and wait it finish
because only 1/10000 JavaFunctionCall::close are running in bthread. the
pthread pool size can set to a small number.
zclllyybb pushed a commit to zclllyybb/doris that referenced this pull request Mar 1, 2026
…#55302)

### What problem does this PR solve?

Related PR: apache#30082

Problem Summary:

We are using doris 3.0.4 with java udf, when running long time, some BE
may got jvm deadlocks with UNKNOWN_owner_addr
[deadlock in udf close]
<img width="2314" height="882" alt="image"
src="https://github.com/user-attachments/assets/c16b5d18-9900-45dc-8bb4-894180694a44"
/>
[deadlock in throwableToStackTrace, waiting a StringWriter , but this is
impossible , because StringWriter was newed everytime]
<img width="1724" height="720" alt="image"
src="https://github.com/user-attachments/assets/b586f752-0ba8-43cc-89b4-352a7d9ab00c"
/>
<img width="618" height="144" alt="image"
src="https://github.com/user-attachments/assets/20c2ad11-beef-4b0c-b2a2-343d9b0fd14c"
/>


In be.WARNING we found  get JNIEnv failed when close udf
<img width="1659" height="426" alt="image"
src="https://github.com/user-attachments/assets/6cf54aa2-522a-407e-a53a-e17fdbc9162e"
/>
In be.out we found libhdfs error log [JNIEnv is got by libhdfs when in
X86 ]
Call to AttachCurrentThread failed with error: -1
getJNIEnv: getGlobalJNIEnv failed

In be.WARNING there are some other err  when using GetJniExceptionMsg
<img width="1686" height="530" alt="image"
src="https://github.com/user-attachments/assets/35ca7b4c-0a9d-4da3-8be2-9a07ccebb74b"
/>

we found all those err has common ground
1.all case occured  in JavaFunctionCall::close
2.the stack all have bthread keyword

after seaching the web , we found that JNI is not compatible with
bthread
https://blog.csdn.net/qq_46104835/article/details/139360911

https://gitee.com/baidu/BRPC/blob/master/docs/cn/server.md#pthread%E6%A8%A1%E5%BC%8F
<img width="1101" height="211" alt="image"
src="https://github.com/user-attachments/assets/e1da2f9a-9e37-47d9-b0a1-c1652da93e75"
/>

the bthread stack layout is not compatible for java, so we may meed
1. AttachCurrentThread[using by getJNIEnv] will check stack layout fail
2. AttachCurrentThread/getJNIEnv may success, but java method may
execute failed, even deadlock, because the stack layout has incompatible
address for jvm


Then we switch bthread to pthread mode , every thing works fine.[add
-usercode_in_pthread=true]

We want to know how often bhread do the JavaFunctionCall::close, then we
add metrics. only 1/10000 JavaFunctionCall::close running in bthread
<img width="1886" height="358" alt="image"
src="https://github.com/user-attachments/assets/34293bac-696b-41f9-b5eb-4daaab81fb7f"
/>

But why JavaFunctionCall::close occured in bthread[ after
apache#16634, exec_plan_fragment is
running in pthread instead of bthread]

then we found a pr
apache#30082

ExchangeSinkBuffer<Parent>::_send_rpc will set a send_callback with a
weak_task_ctx
<img width="1392" height="254" alt="image"
src="https://github.com/user-attachments/assets/a1d28f18-c3c7-4953-baab-d1109f341aa1"
/>
So sometimes send_callback may using weak_task_ctx.lock() to get a
shared_ptr to task_ctx, then task_ctx destructor my be called in
send_callback[ send_callback is running in bthread]

So We modify JavaFunctionCall::close
when JavaFunctionCall::close running in bthread, we submit the jni
operation to a pthread pool, and wait it finish
because only 1/10000 JavaFunctionCall::close are running in bthread. the
pthread pool size can set to a small number.
zclllyybb pushed a commit to zclllyybb/doris that referenced this pull request Mar 1, 2026
…#55302)

### What problem does this PR solve?

Related PR: apache#30082

Problem Summary:

We are using doris 3.0.4 with java udf, when running long time, some BE
may got jvm deadlocks with UNKNOWN_owner_addr
[deadlock in udf close]
<img width="2314" height="882" alt="image"
src="https://github.com/user-attachments/assets/c16b5d18-9900-45dc-8bb4-894180694a44"
/>
[deadlock in throwableToStackTrace, waiting a StringWriter , but this is
impossible , because StringWriter was newed everytime]
<img width="1724" height="720" alt="image"
src="https://github.com/user-attachments/assets/b586f752-0ba8-43cc-89b4-352a7d9ab00c"
/>
<img width="618" height="144" alt="image"
src="https://github.com/user-attachments/assets/20c2ad11-beef-4b0c-b2a2-343d9b0fd14c"
/>


In be.WARNING we found  get JNIEnv failed when close udf
<img width="1659" height="426" alt="image"
src="https://github.com/user-attachments/assets/6cf54aa2-522a-407e-a53a-e17fdbc9162e"
/>
In be.out we found libhdfs error log [JNIEnv is got by libhdfs when in
X86 ]
Call to AttachCurrentThread failed with error: -1
getJNIEnv: getGlobalJNIEnv failed

In be.WARNING there are some other err  when using GetJniExceptionMsg
<img width="1686" height="530" alt="image"
src="https://github.com/user-attachments/assets/35ca7b4c-0a9d-4da3-8be2-9a07ccebb74b"
/>

we found all those err has common ground
1.all case occured  in JavaFunctionCall::close
2.the stack all have bthread keyword

after seaching the web , we found that JNI is not compatible with
bthread
https://blog.csdn.net/qq_46104835/article/details/139360911

https://gitee.com/baidu/BRPC/blob/master/docs/cn/server.md#pthread%E6%A8%A1%E5%BC%8F
<img width="1101" height="211" alt="image"
src="https://github.com/user-attachments/assets/e1da2f9a-9e37-47d9-b0a1-c1652da93e75"
/>

the bthread stack layout is not compatible for java, so we may meed
1. AttachCurrentThread[using by getJNIEnv] will check stack layout fail
2. AttachCurrentThread/getJNIEnv may success, but java method may
execute failed, even deadlock, because the stack layout has incompatible
address for jvm


Then we switch bthread to pthread mode , every thing works fine.[add
-usercode_in_pthread=true]

We want to know how often bhread do the JavaFunctionCall::close, then we
add metrics. only 1/10000 JavaFunctionCall::close running in bthread
<img width="1886" height="358" alt="image"
src="https://github.com/user-attachments/assets/34293bac-696b-41f9-b5eb-4daaab81fb7f"
/>

But why JavaFunctionCall::close occured in bthread[ after
apache#16634, exec_plan_fragment is
running in pthread instead of bthread]

then we found a pr
apache#30082

ExchangeSinkBuffer<Parent>::_send_rpc will set a send_callback with a
weak_task_ctx
<img width="1392" height="254" alt="image"
src="https://github.com/user-attachments/assets/a1d28f18-c3c7-4953-baab-d1109f341aa1"
/>
So sometimes send_callback may using weak_task_ctx.lock() to get a
shared_ptr to task_ctx, then task_ctx destructor my be called in
send_callback[ send_callback is running in bthread]

So We modify JavaFunctionCall::close
when JavaFunctionCall::close running in bthread, we submit the jni
operation to a pthread pool, and wait it finish
because only 1/10000 JavaFunctionCall::close are running in bthread. the
pthread pool size can set to a small number.
HappenLee pushed a commit to HappenLee/incubator-doris that referenced this pull request Apr 24, 2026
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/3.0.0-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants