Skip to content

[fix](fe) Return transaction insert execution errors - #67386

Merged
mymeiyi merged 1 commit into
apache:masterfrom
mymeiyi:fix-sub-txn
Sep 2, 2026
Merged

[fix](fe) Return transaction insert execution errors#67386
mymeiyi merged 1 commit into
apache:masterfrom
mymeiyi:fix-sub-txn

Conversation

@mymeiyi

@mymeiyi mymeiyi commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Transaction INSERT execution failures raised directly while dispatching fragments bypass ErrorReport. OlapTxnInsertExecutor catches these failures and aborts the subtransaction, but previously left QueryState successful, causing the client to receive Query OK. Set the INSERT error state when no earlier error exists so the failure reaches the client while preserving errors already reported by ErrorReport.

Copilot AI lite review requested due to automatic review settings September 1, 2026 11: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?

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Fixes FE behavior so transaction INSERT execution failures correctly surface to clients by setting INSERT error state when appropriate, while keeping already-reported errors intact.

Changes:

  • Add error-state setting in OlapTxnInsertExecutor.onFail() when query state has not already been marked as error.
  • Refactor common error-state construction into OlapInsertExecutor.setErrorState() and reuse it from other executors.
  • Extend regression coverage to inject a fragment execution failure and validate the error is returned during transactional INSERT.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
regression-test/suites/insert_p0/transaction/txn_insert_inject_case.groovy Adds a new injected fragment failure case and refactors debugpoint helpers for reuse.
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/RemoteOlapInsertExecutor.java Switches failure handling to shared setErrorState() logic.
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/OlapTxnInsertExecutor.java Sets MySQL error state on txn insert failure when state was previously left successful.
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/OlapInsertExecutor.java Extracts shared error-state construction into setErrorState() and keeps load-job recording in onFail().
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/insert/OlapGroupCommitInsertExecutor.java Reuses setErrorState() to standardize final error formatting.
Suppressed comments (1)

regression-test/suites/insert_p0/transaction/txn_insert_inject_case.groovy:1

  • After the second injected failure, the test no longer validates that a subsequent INSERT succeeds in the same transaction after the debugpoint is disabled (previously there was another INSERT before COMMIT). This reduces coverage of the 'recover and continue' path. Consider re-adding a post-disable successful INSERT (and/or an assertion on resulting row count) before commit to ensure the transaction remains usable after an injected execution failure.
// Licensed to the Apache Software Foundation (ASF) under one

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mymeiyi

mymeiyi commented Sep 1, 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.

Review opinion: approve. I found no new distinct blocking issue on head 13ae215cb40ec5c35fdd25be8aa763026a53d903.

Critical checkpoint conclusions:

  • Goal and proof: The change closes the client-response gap for explicit-transaction INSERT failures that are caught by executeSingleInsert() before ErrorReport sets QueryState. OlapTxnInsertExecutor.onFail() now supplies a fallback error only when no earlier ERR exists. The regression injects the direct fragment-dispatch failure, requires the client error, then performs and commits a later INSERT in the same transaction; the unchanged ordered six-row result proves the later commit occurred and the failed INSERT did not contribute rows.
  • Scope and parallel paths: The production change is focused. The extracted error-state helper preserves the previous normal OLAP, group-commit, and remote OLAP message construction and abort/load-recording order.
  • Concurrency and lifecycle: No new shared state, lock, or lock ordering is introduced. Failure handling runs on the statement execution path after the coordinator failure is observed. Failed-subtransaction cleanup precedes response-state mutation, successful subtransaction commit information remains intact, and the next statement resets QueryState while retaining the explicit transaction.
  • Transaction, persistence, and data correctness: Both shared-nothing and cloud subtransaction paths retain their existing abort/commit contracts. There is no EditLog, storage-format, visibility-version, delete-bitmap, or FE-BE protocol change.
  • Conditions and error handling: The stateType != ERR guard is necessary and correct: it preserves specific diagnostics already installed by ErrorReport, while direct dispatch exceptions that leave state OK receive the missing client-visible error. Null throwable messages remain normalized to unknown reason.
  • Configuration, compatibility, observability, and performance: No configuration or compatibility surface changes. Existing logs retain query/label/transaction or remote-catalog context. The helper adds no RPC, scan, lock contention, or material hot-path work.
  • Test coverage: The new negative/recovery case complements the existing flush-error path, which continues to exercise preservation of an existing ErrorReport diagnostic. Tests/builds were not run in this review-only runner, as required by the review instructions.
  • Existing review context: The mutable-errMsg helper contract and debug-point cleanup symmetry are already covered by the existing inline threads, so I did not duplicate them.
  • User focus: No additional user-provided review focus was supplied.

Review completion: Round 1 converged. Both complete-review agents and the separate risk-focused agent returned NO_NEW_VALUABLE_FINDINGS; all initial risks were independently resolved, and there are no unresolved candidates or new inline comments.

@mymeiyi

mymeiyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Transaction INSERT execution failures raised directly while dispatching fragments bypass ErrorReport. OlapTxnInsertExecutor catches these failures and aborts the subtransaction, but previously left QueryState successful, causing the client to receive Query OK. In cloud mode, abortSubTxn also populated AbortSubTxnRequest.sub_txn_num with the subtransaction ID instead of the subtransaction count, causing meta-service cleanup to reject the request. Set the INSERT error state using the same final error formatting as other insert executors, and pass the correct subtransaction count during cloud cleanup. Add regression coverage using the BE FragmentMgr.exec_plan_fragment.failed debug point and verify the transaction can still commit after the failed statement.

### Release note

Transaction INSERT execution failures are now returned to clients instead of reporting success.

### Check List (For Author)

- Test: Regression test added; not run per request
- Behavior changed: Yes, transaction INSERT execution failures are returned to the client and cloud cleanup uses the correct subtransaction count
- Does this need documentation: No
@mymeiyi

mymeiyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 42.86% (3/7) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17623	3082	3055	3055
q2	2171	254	231	231
q3	10166	844	511	511
q4	4671	245	202	202
q5	7688	567	403	403
q6	138	112	93	93
q7	523	509	381	381
q8	9249	870	833	833
q9	3439	2378	2352	2352
q10	6514	827	700	700
q11	390	199	184	184
q12	607	259	193	193
q13	18136	1500	1154	1154
q14	158	145	143	143
q15	q16	431	390	361	361
q17	1394	859	860	859
q18	3026	2223	2247	2223
q19	1255	901	792	792
q20	367	303	208	208
q21	5624	1685	1827	1685
q22	331	271	234	234
Total cold run time: 93901 ms
Total hot run time: 16797 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3417	3389	3384	3384
q2	516	394	366	366
q3	2210	2293	2113	2113
q4	1176	1146	886	886
q5	2150	2112	2094	2094
q6	166	118	87	87
q7	1039	944	831	831
q8	1603	1450	1425	1425
q9	3122	3088	3089	3088
q10	1844	1799	1589	1589
q11	353	268	252	252
q12	446	428	336	336
q13	1472	1523	1144	1144
q14	164	168	155	155
q15	q16	389	393	353	353
q17	3541	3330	3249	3249
q18	4773	4384	4702	4384
q19	874	821	893	821
q20	1010	951	826	826
q21	3807	3107	3247	3107
q22	399	336	338	336
Total cold run time: 34471 ms
Total hot run time: 30826 ms

@hello-stephen

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

query5	4240	409	341	341
query6	387	134	128	128
query7	4965	422	227	227
query8	312	125	117	117
query9	8692	2889	2867	2867
query10	401	222	183	183
query11	5382	1029	911	911
query12	121	71	71	71
query13	1198	434	325	325
query14	6161	2242	2130	2130
query14_1	1989	2015	1986	1986
query15	180	128	115	115
query16	923	370	367	367
query17	817	486	368	368
query18	2347	334	234	234
query19	173	141	115	115
query20	77	72	70	70
query21	200	102	87	87
query22	5306	5236	5309	5236
query23	6778	6156	5864	5864
query23_1	5924	6194	6197	6194
query24	7262	1098	764	764
query24_1	783	777	763	763
query25	474	322	270	270
query26	1232	228	128	128
query27	2801	419	260	260
query28	4675	1485	1518	1485
query29	933	457	365	365
query30	260	162	132	132
query31	825	399	330	330
query32	127	78	81	78
query33	473	235	181	181
query34	991	818	489	489
query35	415	405	349	349
query36	570	558	551	551
query37	121	79	73	73
query38	1010	848	812	812
query39	501	481	477	477
query39_1	469	454	450	450
query40	206	97	83	83
query41	59	57	91	57
query42	78	70	70	70
query43	239	240	209	209
query44	1010	573	556	556
query45	114	102	109	102
query46	769	851	511	511
query47	773	767	708	708
query48	302	303	236	236
query49	538	229	184	184
query50	744	255	190	190
query51	8052	7896	8181	7896
query52	70	66	58	58
query53	183	198	173	173
query54	222	181	152	152
query55	75	60	53	53
query56	205	161	186	161
query57	699	691	627	627
query58	205	179	178	178
query59	1194	1223	1104	1104
query60	253	201	175	175
query61	113	130	135	130
query62	365	202	182	182
query63	174	143	142	142
query64	2699	698	595	595
query65	1632	1614	1613	1613
query66	1804	259	199	199
query67	9644	9661	9804	9661
query68	2989	1212	740	740
query69	358	218	189	189
query70	682	638	607	607
query71	259	164	172	164
query72	2521	1727	1525	1525
query73	647	585	336	336
query74	1998	1223	1147	1147
query75	1179	1089	961	961
query76	2386	743	532	532
query77	257	266	214	214
query78	4084	3756	3228	3228
query79	2274	786	576	576
query80	1600	333	281	281
query81	506	156	131	131
query82	633	120	94	94
query83	285	210	193	193
query84	304	110	90	90
query85	800	373	293	293
query86	394	191	168	168
query87	1032	967	894	894
query88	2798	2140	2087	2087
query89	298	192	179	179
query90	1978	126	131	126
query91	134	121	101	101
query92	76	69	69	69
query93	1458	1094	698	698
query94	651	242	223	223
query95	530	330	240	240
query96	782	550	267	267
query97	1035	1041	1045	1041
query98	145	145	136	136
query99	425	336	311	311
Total cold run time: 177832 ms
Total hot run time: 81938 ms

@hello-stephen

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

query1	0.00	0.00	0.01
query2	0.09	0.04	0.04
query3	0.26	0.12	0.11
query4	1.61	0.10	0.11
query5	0.17	0.15	0.16
query6	1.24	0.70	0.71
query7	0.04	0.01	0.00
query8	0.05	0.03	0.03
query9	0.28	0.21	0.22
query10	0.34	0.36	0.35
query11	0.17	0.12	0.11
query12	0.14	0.12	0.12
query13	0.30	0.30	0.29
query14	0.44	0.46	0.44
query15	0.36	0.35	0.35
query16	0.23	0.20	0.21
query17	0.71	0.68	0.67
query18	0.18	0.16	0.17
query19	1.15	1.16	1.12
query20	0.02	0.01	0.01
query21	15.44	0.16	0.13
query22	5.06	0.04	0.04
query23	16.15	0.24	0.10
query24	3.00	0.29	0.30
query25	0.11	0.04	0.04
query26	0.78	0.16	0.12
query27	0.04	0.03	0.03
query28	3.63	0.57	0.28
query29	12.43	3.19	2.59
query30	0.25	0.12	0.12
query31	2.76	0.38	0.17
query32	3.50	0.30	0.23
query33	1.55	1.35	1.49
query34	15.36	2.24	1.77
query35	1.75	1.70	1.70
query36	0.45	0.30	0.27
query37	0.06	0.04	0.05
query38	0.05	0.04	0.03
query39	0.03	0.02	0.02
query40	0.12	0.07	0.08
query41	0.08	0.02	0.03
query42	0.04	0.02	0.02
query43	0.03	0.03	0.02
Total cold run time: 90.45 s
Total hot run time: 14.61 s

@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

@mymeiyi

mymeiyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

run nonConcurrent

@mymeiyi

mymeiyi commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

run feut

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 42.86% (3/7) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 4.23% (6/142) 🎉
Increment coverage report
Complete coverage report

@mymeiyi
mymeiyi merged commit 72071af into apache:master Sep 2, 2026
33 of 35 checks passed
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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

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.1.x dev/4.1.x-conflict reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants