Skip to content

[fix](routine-load) Set cancel reason when parsing create routine load stmt failed in gsonPostProcess - #66173

Open
re20052 wants to merge 1 commit into
apache:masterfrom
re20052:fix-routine-load-cancel-reason
Open

[fix](routine-load) Set cancel reason when parsing create routine load stmt failed in gsonPostProcess#66173
re20052 wants to merge 1 commit into
apache:masterfrom
re20052:fix-routine-load-cancel-reason

Conversation

@re20052

@re20052 re20052 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Problem Summary:
When FE restarts and replays routine load jobs via gsonPostProcess, if parsing the original SQL statement fails, the job state is set to CANCELLED but the cancelReason is left null. This causes the ReasonOfStateChanged column to be empty when users execute SHOW ALL ROUTINE LOAD;, hiding the actual failure cause.
This PR sets the exception message as the cancelReason when parsing fails, so users can see the exact reason (e.g. table not found) from the SHOW ALL ROUTINE LOAD; result.

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

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

@re20052

re20052 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

/review

@re20052

re20052 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 0.00% (0/1) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17735	4220	4090	4090
q2	2076	317	197	197
q3	10296	1439	809	809
q4	4684	459	342	342
q5	7502	864	561	561
q6	179	173	133	133
q7	776	802	593	593
q8	9390	1524	1527	1524
q9	5578	4372	4369	4369
q10	6760	1773	1488	1488
q11	510	358	325	325
q12	719	588	456	456
q13	18104	3358	2777	2777
q14	269	262	244	244
q15	q16	788	778	706	706
q17	1050	1038	948	948
q18	6845	5809	5518	5518
q19	1387	1285	1128	1128
q20	777	680	575	575
q21	6013	2535	2450	2450
q22	438	353	296	296
Total cold run time: 101876 ms
Total hot run time: 29529 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4379	4304	4326	4304
q2	291	321	212	212
q3	4619	4926	4406	4406
q4	2053	2156	1344	1344
q5	4364	4293	4255	4255
q6	227	173	124	124
q7	1735	1829	1859	1829
q8	2565	2150	2173	2150
q9	7937	8060	7758	7758
q10	4701	4668	4252	4252
q11	579	412	386	386
q12	758	771	540	540
q13	3251	3641	2893	2893
q14	309	298	281	281
q15	q16	704	748	665	665
q17	1312	1316	1300	1300
q18	8105	7389	7400	7389
q19	1148	1128	1131	1128
q20	2208	2204	1921	1921
q21	5191	4528	4355	4355
q22	508	459	405	405
Total cold run time: 56944 ms
Total hot run time: 51897 ms

@hello-stephen

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

query5	4300	601	479	479
query6	460	215	198	198
query7	4885	593	341	341
query8	341	181	169	169
query9	8778	4001	3991	3991
query10	493	364	317	317
query11	5928	2288	2113	2113
query12	157	105	99	99
query13	1262	550	423	423
query14	6247	5188	4854	4854
query14_1	4201	4238	4198	4198
query15	216	206	176	176
query16	1028	485	473	473
query17	1140	722	574	574
query18	2453	487	346	346
query19	212	191	157	157
query20	114	112	109	109
query21	235	157	137	137
query22	13497	13594	13350	13350
query23	17503	16500	16131	16131
query23_1	16243	16223	16250	16223
query24	7534	1718	1254	1254
query24_1	1306	1296	1253	1253
query25	583	478	401	401
query26	1334	362	211	211
query27	2571	586	384	384
query28	4453	1949	1968	1949
query29	1081	640	495	495
query30	331	262	225	225
query31	1116	1097	989	989
query32	110	62	63	62
query33	529	322	258	258
query34	1172	1109	637	637
query35	769	767	674	674
query36	1044	1031	913	913
query37	155	112	94	94
query38	1882	1708	1649	1649
query39	873	901	864	864
query39_1	832	849	848	848
query40	247	160	144	144
query41	64	63	60	60
query42	93	91	87	87
query43	317	316	277	277
query44	1386	746	739	739
query45	194	178	174	174
query46	1072	1159	711	711
query47	2141	2137	2027	2027
query48	411	412	307	307
query49	575	407	305	305
query50	1087	430	352	352
query51	10674	10427	10533	10427
query52	87	85	75	75
query53	279	278	210	210
query54	295	237	219	219
query55	73	68	64	64
query56	305	280	299	280
query57	1318	1315	1198	1198
query58	298	264	238	238
query59	1588	1640	1444	1444
query60	300	278	255	255
query61	154	147	149	147
query62	543	493	430	430
query63	242	197	201	197
query64	2839	1099	855	855
query65	4735	4617	4663	4617
query66	1825	502	436	436
query67	29189	29109	29054	29054
query68	3091	1560	1026	1026
query69	403	299	266	266
query70	907	829	827	827
query71	368	325	316	316
query72	3000	2659	2371	2371
query73	859	794	422	422
query74	5059	4863	4726	4726
query75	2518	2481	2126	2126
query76	2306	1156	760	760
query77	363	383	278	278
query78	11961	12000	11212	11212
query79	1386	1139	756	756
query80	1312	536	467	467
query81	513	333	288	288
query82	587	159	118	118
query83	402	309	292	292
query84	287	164	134	134
query85	995	613	529	529
query86	398	240	233	233
query87	1819	1814	1742	1742
query88	3669	2767	2758	2758
query89	431	376	331	331
query90	1884	199	193	193
query91	203	192	162	162
query92	62	63	58	58
query93	1623	1616	931	931
query94	699	362	304	304
query95	779	495	462	462
query96	1087	795	336	336
query97	2604	2654	2522	2522
query98	207	208	200	200
query99	1102	1119	963	963
Total cold run time: 262979 ms
Total hot run time: 176438 ms

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.13	0.05	0.05
query3	0.25	0.13	0.13
query4	1.60	0.13	0.14
query5	0.23	0.22	0.22
query6	1.28	1.05	1.06
query7	0.04	0.00	0.01
query8	0.06	0.04	0.04
query9	0.39	0.31	0.30
query10	0.56	0.54	0.56
query11	0.19	0.13	0.14
query12	0.17	0.14	0.14
query13	0.46	0.47	0.47
query14	1.03	1.02	1.03
query15	0.61	0.58	0.59
query16	0.34	0.32	0.33
query17	1.14	1.07	1.14
query18	0.21	0.20	0.19
query19	2.02	1.94	1.97
query20	0.02	0.01	0.02
query21	15.43	0.22	0.13
query22	4.84	0.05	0.06
query23	16.12	0.31	0.12
query24	2.91	0.42	0.33
query25	0.11	0.05	0.04
query26	0.73	0.22	0.15
query27	0.05	0.04	0.03
query28	3.55	0.86	0.54
query29	12.51	4.16	3.29
query30	0.27	0.16	0.15
query31	2.77	0.60	0.31
query32	3.23	0.58	0.49
query33	3.19	3.22	3.28
query34	15.50	4.22	3.53
query35	3.49	3.46	3.55
query36	0.55	0.45	0.44
query37	0.09	0.07	0.07
query38	0.04	0.03	0.04
query39	0.04	0.03	0.04
query40	0.19	0.17	0.16
query41	0.08	0.03	0.04
query42	0.04	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 96.51 s
Total hot run time: 25 s

@BePPPower

Copy link
Copy Markdown
Contributor

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

Request changes: the new reason is visible immediately for most parser/validation failures, but it is neither checkpoint-durable nor actionable for the missing-database path; see the inline finding.

Critical checkpoints:

  • Goal and tests: The one-line assignment reaches both SHOW ROUTINE LOAD and the FE RPC, but the two cases above leave the requested diagnostic empty or generic. No existing test invokes a failing gsonPostProcess and verifies display plus checkpoint/reload behavior.
  • Scope and clarity: The edit is small and focused, but persisting the diagnostic and using a context-rich database lookup are required for the stated end-to-end behavior.
  • Concurrency and lifecycle: Image deserialization occurs before manager publication, so the assignment adds no lock or race risk. The relevant lifecycle is image load -> post-process -> checkpoint -> reload; that lifecycle exposes the durability defect.
  • Configuration and compatibility: No configuration, FE-BE protocol, symbol, or storage-format incompatibility is introduced. An optional serialized reason must remain backward-readable.
  • Parallel paths and conditions: Kafka/Kinesis subclasses share this base path. SQL SHOW and the FE RPC both call getStateReason, so both are affected. The concrete special case is an absent database before parsing begins.
  • Testing and results: No local build or test was run because the authoritative review prompt forbids builds. Existing CI compile, FE UT, and regression checks pass. The FE coverage job failure is infrastructure-related (missing avro-scanner.jar while producing its report), not proof of this change's coverage.
  • Observability, persistence, and data safety: The existing warning log retains the stack trace, but the user-facing reason needs the fixes above. No transaction, table-data write, visible-version, or FE-BE variable propagation path changes.
  • Performance and other risks: The exceptional-path allocation is negligible. No additional correctness, locking, configuration, compatibility, or performance issue was substantiated.

User focus: no additional focus was supplied; the full PR was reviewed.

Review status: complete for reviewed head 928c7cba3893349ea70408f87b65613c6c4bd676 after convergence.

}
} catch (Exception e) {
this.state = JobState.CANCELLED;
this.cancelReason = new ErrorReason(InternalErrorCode.INTERNAL_ERR, e.getMessage());

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.

[P1] Make the reported cancellation reason durable and actionable

This assignment fixes only the current deserialization. RoutineLoadJob.write() uses GsonUtils.GSON, whose HiddenAnnotationExclusionStrategy omits fields without @SerializedName; cancelReason is unannotated even though state is persisted. A later checkpoint can therefore store CANCELLED but drop this reason, and if the original statement validates on the next restart, SHOW ALL ROUTINE LOAD is empty again. There is also a first-load path where getDb(dbId).get() handles a missing database by throwing NoSuchElementException, so e.getMessage() is only "No value present" and does not identify the database. Please use a context-rich lookup, persist the reason without overwriting an already persisted terminal reason, and add a failing-postprocess -> SHOW/RPC -> checkpoint -> reload test (including the missing-database case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants