Skip to content

[test](fe) Cover internal query audit failure in FE unit test#65696

Merged
morrySnow merged 1 commit into
apache:masterfrom
yujun777:fix/audit-log-fe-ut
Jul 17, 2026
Merged

[test](fe) Cover internal query audit failure in FE unit test#65696
morrySnow merged 1 commit into
apache:masterfrom
yujun777:fix/audit-log-fe-ut

Conversation

@yujun777

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

The previous regression coverage for internal query audit failures depended on querying __internal_schema.audit_log after a fault-injection failure. That path is timing-sensitive because audit persistence is asynchronous, so the regression can fail even when StmtExecutor.executeInternalQuery() already reports the error audit event correctly.

This PR replaces that flaky coverage with a deterministic FE unit test. The new test forces a planning failure in executeInternalQuery() and verifies that the submitted AuditEvent is marked as ERR and carries the failure details. The unstable fault-injection regression case is removed.

Release note

None

Replace the flaky regression case that polls __internal_schema.audit_log with a
deterministic FE unit test that verifies executeInternalQuery submits an ERR
audit event when planning fails.

Key changes:
- mock NereidsPlanner planning failure in StmtExecutorInternalQueryTest
- verify the submitted AuditEvent records ERR state and failure details
- remove the unstable fault-injection regression case

Unit Test:
- ./run-fe-ut.sh --run org.apache.doris.qe.StmtExecutorInternalQueryTest
@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?

@yujun777

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17759	4177	4149	4149
q2	2038	327	197	197
q3	10316	1393	805	805
q4	4682	477	345	345
q5	7518	878	562	562
q6	186	176	138	138
q7	750	810	634	634
q8	9362	1548	1513	1513
q9	5498	4367	4317	4317
q10	6810	1706	1478	1478
q11	523	350	335	335
q12	722	572	456	456
q13	18112	3431	2760	2760
q14	269	267	237	237
q15	q16	782	775	705	705
q17	949	980	904	904
q18	6891	5817	5542	5542
q19	1308	1192	1162	1162
q20	815	697	587	587
q21	5950	2633	2383	2383
q22	426	354	297	297
Total cold run time: 101666 ms
Total hot run time: 29506 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4419	4347	4399	4347
q2	301	324	211	211
q3	4547	4916	4378	4378
q4	2045	2157	1352	1352
q5	4404	4311	4295	4295
q6	233	177	133	133
q7	1744	1882	1821	1821
q8	2594	2252	2265	2252
q9	7962	8156	7886	7886
q10	4641	4637	4220	4220
q11	576	431	401	401
q12	763	772	536	536
q13	3366	3644	2966	2966
q14	308	298	285	285
q15	q16	753	734	648	648
q17	1374	1319	1357	1319
q18	8069	7331	7340	7331
q19	1213	1114	1110	1110
q20	2233	2199	1925	1925
q21	5241	4550	4357	4357
q22	500	456	407	407
Total cold run time: 57286 ms
Total hot run time: 52180 ms

@hello-stephen

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

query5	4329	635	485	485
query6	454	227	207	207
query7	4865	633	341	341
query8	358	192	177	177
query9	8800	4053	4042	4042
query10	474	365	314	314
query11	5839	2328	2118	2118
query12	158	99	99	99
query13	1236	596	447	447
query14	6218	5197	4865	4865
query14_1	4235	4220	4272	4220
query15	202	194	181	181
query16	995	478	443	443
query17	917	713	538	538
query18	2447	470	342	342
query19	202	178	141	141
query20	108	110	106	106
query21	237	161	133	133
query22	13728	13692	13301	13301
query23	17198	16473	16086	16086
query23_1	16153	16245	16251	16245
query24	7546	1767	1293	1293
query24_1	1296	1264	1292	1264
query25	567	456	386	386
query26	1332	373	212	212
query27	2633	612	380	380
query28	4507	1988	2008	1988
query29	1094	634	492	492
query30	344	265	242	242
query31	1134	1096	971	971
query32	112	66	63	63
query33	543	322	253	253
query34	1166	1196	619	619
query35	786	794	673	673
query36	1198	1170	1036	1036
query37	151	109	93	93
query38	1883	1682	1654	1654
query39	858	877	841	841
query39_1	820	831	838	831
query40	244	173	144	144
query41	71	68	69	68
query42	93	94	96	94
query43	326	330	288	288
query44	1395	782	766	766
query45	202	192	181	181
query46	1105	1155	710	710
query47	2119	2171	1996	1996
query48	408	435	294	294
query49	600	435	308	308
query50	1068	439	339	339
query51	10708	10357	10906	10357
query52	87	90	76	76
query53	274	282	209	209
query54	303	256	230	230
query55	76	75	67	67
query56	304	322	332	322
query57	1326	1304	1195	1195
query58	308	261	255	255
query59	1613	1627	1442	1442
query60	323	283	275	275
query61	183	195	149	149
query62	539	494	437	437
query63	243	196	217	196
query64	2828	1019	835	835
query65	4584	4622	4628	4622
query66	1848	521	376	376
query67	29369	29145	29064	29064
query68	3339	1557	1035	1035
query69	419	306	261	261
query70	1075	913	978	913
query71	358	330	330	330
query72	3071	2911	2331	2331
query73	808	770	403	403
query74	5072	4845	4694	4694
query75	2530	2487	2139	2139
query76	2350	1161	767	767
query77	350	373	287	287
query78	11956	11839	11303	11303
query79	1351	1137	739	739
query80	649	539	453	453
query81	465	335	290	290
query82	571	154	123	123
query83	410	318	295	295
query84	327	162	128	128
query85	934	655	521	521
query86	359	303	282	282
query87	1834	1820	1724	1724
query88	3663	2742	2764	2742
query89	430	382	323	323
query90	1951	197	193	193
query91	201	192	167	167
query92	61	64	56	56
query93	1572	1501	928	928
query94	553	340	314	314
query95	810	534	455	455
query96	1053	808	346	346
query97	2626	2600	2535	2535
query98	215	201	197	197
query99	1085	1117	964	964
Total cold run time: 262400 ms
Total hot run time: 177094 ms

@yujun777

Copy link
Copy Markdown
Contributor Author

run feut

@hello-stephen

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

query1	0.00	0.00	0.00
query2	0.10	0.05	0.06
query3	0.26	0.17	0.13
query4	1.61	0.14	0.14
query5	0.24	0.22	0.22
query6	1.26	1.06	1.05
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.40	0.31	0.33
query10	0.55	0.59	0.53
query11	0.19	0.14	0.13
query12	0.18	0.15	0.14
query13	0.46	0.46	0.48
query14	1.00	0.99	1.02
query15	0.60	0.58	0.59
query16	0.32	0.31	0.31
query17	1.14	1.11	1.13
query18	0.22	0.22	0.21
query19	1.99	1.96	2.01
query20	0.02	0.01	0.01
query21	15.43	0.20	0.13
query22	4.94	0.06	0.05
query23	16.14	0.32	0.12
query24	2.89	0.42	0.32
query25	0.12	0.05	0.05
query26	0.75	0.20	0.16
query27	0.04	0.04	0.04
query28	3.53	0.88	0.51
query29	12.47	4.12	3.27
query30	0.27	0.15	0.16
query31	2.78	0.61	0.31
query32	3.22	0.60	0.49
query33	3.22	3.28	3.22
query34	15.48	4.24	3.51
query35	3.53	3.51	3.52
query36	0.54	0.43	0.42
query37	0.10	0.07	0.07
query38	0.05	0.03	0.03
query39	0.03	0.02	0.02
query40	0.18	0.17	0.16
query41	0.08	0.04	0.03
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.01 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage `` 🎉
Increment coverage report
Complete coverage report

@morrySnow

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.

Automated review completed. I found no blocking correctness issue and no inline finding to submit.

Critical checkpoint conclusions:

  • Goal and proof: This test-only PR replaces the timing-sensitive audit-table polling case with a deterministic FE unit test. The new test proves that a failed internal query reaches AuditLogHelper, submits an AFTER_QUERY event, and preserves ERR, the internal error code/message, internal/query/Nereids flags, SQL text, and SQL hash.
  • Scope and clarity: The change is small and focused. The added getStatementContext() stubs are necessary for the mocked planner to pass through the audit metadata branch instead of being stopped by a mock-induced null dereference.
  • Parallel paths and conditions: Parse/plan, coordinator execution, and result-fetch failures currently converge on the same outer error-state catch and audit finally. The workload-status queue and audit processor pass the same event object onward, changing only runtime statistics, and the audit loader serializes the reviewed state/error/internal fields directly. I found no distinct current failure branch left uncovered by the new state-to-event test.
  • Concurrency and lifecycle: No production concurrency or lifecycle behavior changes. The test restores the temporary Env.workloadRuntimeStatusMgr replacement in finally; FE test classes run in non-reused JVM forks, no method-parallel mode is configured, and this test does not start the workload-status daemon, so no race or singleton leak was substantiated.
  • Configuration, compatibility, persistence, data writes, and FE/BE variables: No production configuration, protocol, storage-format, transaction, persistence, data-write, or FE/BE variable-passing change is present.
  • Performance and observability: No production hot path or observability behavior is modified.
  • Test coverage and results: The FE unit test, compile check, NonConcurrent Regression, and P0 Regression checks pass. The separate FE incremental-coverage check is red because this PR changes no production Java lines: its bot report contains a blank incremental value and the incremental report URL is absent, while the complete coverage report exists. I treated that as reporting infrastructure rather than a code defect. No local build was run because the review contract prohibits builds in this runner.
  • User focus: No additional user-provided focus point was supplied; the complete PR was reviewed.

Review opinion: ready from a code-review perspective.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants