Skip to content

[fix](load) fix empty statistics for forwarded INSERT#64439

Merged
gavinchou merged 2 commits into
apache:masterfrom
sollhui:fix_insert_select_stat
Jun 12, 2026
Merged

[fix](load) fix empty statistics for forwarded INSERT#64439
gavinchou merged 2 commits into
apache:masterfrom
sollhui:fix_insert_select_stat

Conversation

@sollhui

@sollhui sollhui commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

When INSERT INTO ... SELECT is forwarded from a follower FE to the master FE, SHOW LOAD could show an empty JobDetails, such as ScannedRows=0, LoadBytes=0, TaskNumber=0, and empty backend lists.

The root cause is that the insert load job is registered with a real jobId, but when coordinator creation falls back to the regular Coordinator / CloudCoordinator path, that jobId was not passed into the coordinator. Therefore, the coordinator kept the default jobId=-1 and did not initialize or update the corresponding LoadManager progress. The load job was still recorded as FINISHED, but its LoadStatistic remained empty when SHOW LOAD rendered JobDetails.

This PR preserves the insert jobId in the regular Coordinator and CloudCoordinator fallback paths, so initJobProgress() and updateJobProgress() update the same InsertLoadJob that is later recorded and displayed by SHOW LOAD.

@sollhui sollhui requested a review from gavinchou as a code owner June 12, 2026 02:27
@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?

@sollhui

sollhui commented Jun 12, 2026

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.

Requesting changes for missing regression coverage of the exact bug path.

Critical checkpoint conclusions:

  • Goal: the current four-file diff preserves jobId when EnvFactory/CloudEnvFactory fall back to legacy Coordinator/CloudCoordinator, so BE progress reports can update the existing InsertLoadJob instead of job -1.
  • Scope: the code change is small and focused; both shared-nothing and cloud fallback paths were updated.
  • Concurrency/lifecycle/config/compatibility: no new concurrency, lifecycle, configuration, protocol, or storage-format behavior was introduced.
  • Parallel paths: the parallel cloud and non-cloud coordinator factory paths are both covered.
  • Data writes/persistence: the fix uses the existing LoadManager.initJobProgress/updateJobProgress and finished-job snapshot flow; preserving the id is the right state handoff for SHOW LOAD.JobDetails.
  • Performance/observability: no meaningful hot-path cost was added; existing load-progress reporting and warnings remain the observability path.
  • Tests: missing. Existing test_insert_statistic covers normal INSERT ... SELECT statistics, but it does not exercise the follower-FE proxy path this PR fixes. The existing docker suite test_insert_from_follower already creates a 3-FE cluster and should be extended to assert the labeled INSERT ... SELECT SHOW LOAD.JobDetails values.
  • User focus: no additional user-provided focus points were supplied.

Comment thread fe/fe-core/src/main/java/org/apache/doris/catalog/EnvFactory.java
@sollhui

sollhui commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17596	4065	3992	3992
q2	q3	10756	1339	801	801
q4	4686	474	340	340
q5	7528	864	574	574
q6	185	168	135	135
q7	787	829	624	624
q8	9485	1595	1528	1528
q9	6229	4515	4508	4508
q10	6829	1822	1517	1517
q11	442	272	252	252
q12	652	417	299	299
q13	18136	3385	2791	2791
q14	272	261	251	251
q15	q16	828	784	702	702
q17	1779	1121	799	799
q18	6710	5707	5581	5581
q19	1534	1282	1021	1021
q20	506	399	254	254
q21	5787	2572	2400	2400
q22	435	363	296	296
Total cold run time: 101162 ms
Total hot run time: 28665 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4370	4256	4292	4256
q2	q3	4504	4958	4286	4286
q4	2089	2196	1393	1393
q5	4425	4262	4304	4262
q6	223	170	126	126
q7	1729	1613	1753	1613
q8	2595	2167	2156	2156
q9	7912	7890	7930	7890
q10	4801	4745	4316	4316
q11	616	414	372	372
q12	784	750	552	552
q13	3503	3688	2964	2964
q14	302	313	284	284
q15	q16	707	781	675	675
q17	1362	1324	1337	1324
q18	8110	7382	7118	7118
q19	1091	1086	1095	1086
q20	2223	2233	1970	1970
q21	5270	4591	4394	4394
q22	540	487	405	405
Total cold run time: 57156 ms
Total hot run time: 51442 ms

@hello-stephen

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

query5	4312	614	476	476
query6	446	180	176	176
query7	4811	590	312	312
query8	368	207	204	204
query9	8735	3986	4024	3986
query10	460	294	252	252
query11	5901	2329	2175	2175
query12	159	102	95	95
query13	1275	605	441	441
query14	6388	5401	5055	5055
query14_1	4416	4381	4371	4371
query15	198	197	177	177
query16	970	438	415	415
query17	1081	676	564	564
query18	2413	484	334	334
query19	193	175	136	136
query20	114	106	107	106
query21	214	136	118	118
query22	13580	13546	13463	13463
query23	17098	16512	16108	16108
query23_1	16344	16286	16701	16286
query24	7616	1771	1336	1336
query24_1	1306	1278	1303	1278
query25	542	444	373	373
query26	1310	316	165	165
query27	2663	567	354	354
query28	4487	2014	2025	2014
query29	1116	627	502	502
query30	310	243	201	201
query31	1114	1088	958	958
query32	104	65	60	60
query33	555	323	256	256
query34	1182	1136	667	667
query35	758	799	695	695
query36	1402	1437	1262	1262
query37	154	105	91	91
query38	3192	3149	3057	3057
query39	924	919	902	902
query39_1	889	876	879	876
query40	236	125	107	107
query41	76	67	67	67
query42	98	99	99	99
query43	347	325	280	280
query44	
query45	196	188	177	177
query46	1093	1189	763	763
query47	2382	2385	2239	2239
query48	413	405	302	302
query49	633	481	361	361
query50	981	359	256	256
query51	4803	4302	4307	4302
query52	91	92	89	89
query53	243	279	194	194
query54	287	228	204	204
query55	80	77	70	70
query56	245	249	241	241
query57	1408	1421	1342	1342
query58	257	225	212	212
query59	1603	1632	1440	1440
query60	326	242	247	242
query61	151	145	145	145
query62	699	645	605	605
query63	231	187	183	183
query64	2513	773	599	599
query65	
query66	1784	457	346	346
query67	29660	29769	29660	29660
query68	
query69	418	298	263	263
query70	950	974	961	961
query71	314	223	207	207
query72	2924	2647	2275	2275
query73	840	782	438	438
query74	5116	4985	4766	4766
query75	2638	2568	2261	2261
query76	2359	1138	775	775
query77	359	377	290	290
query78	12384	12488	11794	11794
query79	1481	1060	781	781
query80	1231	475	400	400
query81	524	283	240	240
query82	586	160	123	123
query83	315	274	241	241
query84	
query85	860	516	410	410
query86	432	306	287	287
query87	3388	3408	3129	3129
query88	3628	2741	2758	2741
query89	431	384	325	325
query90	1866	180	172	172
query91	176	168	139	139
query92	70	61	53	53
query93	1548	1434	954	954
query94	701	348	325	325
query95	689	456	364	364
query96	1007	832	348	348
query97	2746	2706	2562	2562
query98	223	202	212	202
query99	1131	1201	1040	1040
Total cold run time: 251581 ms
Total hot run time: 168656 ms

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 57.14% (4/7) 🎉
Increment coverage report
Complete coverage report

@liaoxin01 liaoxin01 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 github-actions Bot added the approved Indicates a PR has been approved by one committer. label Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (7/7) 🎉
Increment coverage report
Complete coverage report

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@gavinchou gavinchou merged commit a53679b into apache:master Jun 12, 2026
36 checks passed
github-actions Bot pushed a commit that referenced this pull request Jun 12, 2026
### What problem does this PR solve?

When `INSERT INTO ... SELECT` is forwarded from a follower FE to the
master FE, `SHOW LOAD` could show an empty `JobDetails`, such as
`ScannedRows=0`, `LoadBytes=0`, `TaskNumber=0`, and empty backend lists.

The root cause is that the insert load job is registered with a real
`jobId`, but when coordinator creation falls back to the regular
`Coordinator` / `CloudCoordinator` path, that `jobId` was not passed
into the coordinator. Therefore, the coordinator kept the default
`jobId=-1` and did not initialize or update the corresponding
`LoadManager` progress. The load job was still recorded as `FINISHED`,
but its `LoadStatistic` remained empty when `SHOW LOAD` rendered
`JobDetails`.

This PR preserves the insert `jobId` in the regular `Coordinator` and
`CloudCoordinator` fallback paths, so `initJobProgress()` and
`updateJobProgress()` update the same `InsertLoadJob` that is later
recorded and displayed by `SHOW LOAD`.
github-actions Bot pushed a commit that referenced this pull request Jun 12, 2026
### What problem does this PR solve?

When `INSERT INTO ... SELECT` is forwarded from a follower FE to the
master FE, `SHOW LOAD` could show an empty `JobDetails`, such as
`ScannedRows=0`, `LoadBytes=0`, `TaskNumber=0`, and empty backend lists.

The root cause is that the insert load job is registered with a real
`jobId`, but when coordinator creation falls back to the regular
`Coordinator` / `CloudCoordinator` path, that `jobId` was not passed
into the coordinator. Therefore, the coordinator kept the default
`jobId=-1` and did not initialize or update the corresponding
`LoadManager` progress. The load job was still recorded as `FINISHED`,
but its `LoadStatistic` remained empty when `SHOW LOAD` rendered
`JobDetails`.

This PR preserves the insert `jobId` in the regular `Coordinator` and
`CloudCoordinator` fallback paths, so `initJobProgress()` and
`updateJobProgress()` update the same `InsertLoadJob` that is later
recorded and displayed by `SHOW LOAD`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants