Skip to content

[fix](fe) Preserve SQL formatting when masking FE logs - #69467

Merged
gavinchou merged 2 commits into
apache:masterfrom
gavinchou:gavin-mask-fe-log-preserve-format
Nov 23, 2026
Merged

gavinchou merged 2 commits into
apache:masterfrom
gavinchou:gavin-mask-fe-log-preserve-format

Conversation

@gavinchou

@gavinchou gavinchou commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: N/A

Problem Summary:

SQL masking in FE execution logs rebuilds entire property lists, losing their line breaks, indentation, comments and original key formatting. Some retry, internal query and HTTP stream planning logs also print the original SQL. Parser exceptions can repeat the original SQL in their diagnostic text even when the main log message uses a masked statement.

Reuse the audit masking parser and the existing sensitive/hidden property key policies, with a formatting-preserving mode that replaces only sensitive values. Use this shared path for StmtExecutor SQL logs before and after parsing, including statements whose audit-encryption flag is false. Normalize parser replacement ranges to inclusive UTF-16 offsets for both formatting modes and direct streaming callers, so supplementary Unicode characters cannot shift the masked ranges. Keep audit logging's existing formatting and dispatch behavior.

Masking failures return a fixed placeholder. Logs for masking and syntax failures record the exception type without input-bearing exception messages or stack traces. Logging pre-processing does not apply execution hints.

Release note

FE execution logs preserve SQL line breaks and formatting while masking recognized credential values. Syntax-error diagnostics no longer repeat the original SQL. Supplementary Unicode characters no longer leave recognized credentials unmasked in audit SQL.

Check List (For Author)

  • Test
    • Unit Test: 58 focused tests passed: EncryptSQLTest (12), RepositoryAuditEncryptionTest (5), AuditEncryptionSessionVariableTest (1), DatasourcePrintableMapTest (20), StreamingInsertTaskAuditTest (11), and StmtExecutorTest (9 selected methods). Coverage includes default audit masking, both formatting modes, supplementary characters, multiple direct-parser ranges, existing output policies and execution-log failure handling.
    • Regression test
    • Manual test
    • Checkstyle: passed with zero violations.
  • Behavior changed:
    • Yes. FE SQL logs preserve formatting and consistently mask recognized credentials; audit formatting and dispatch remain unchanged; Unicode range correction also protects audit and streaming callers.
  • Does this need documentation?
    • No. No configuration or SQL interface changes.

Check List (For Reviewer who merge this PR)

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

### What problem does this PR solve?

Issue Number: N/A

Problem Summary: Rebuilding SQL property lists for FE log masking loses
line breaks, indentation and comments. Some execution-log paths still use
the original SQL, and parser diagnostics can repeat credentials even when
the primary log message is masked.

Share the audit masking parser and sensitive-property policy while adding
a mode that replaces only value ranges in the original SQL. Use that mode
consistently before and after parsing, independently of the audit gate.
Translate code-point offsets to UTF-16 offsets to handle supplementary
characters correctly. Keep the audit log's existing formatting and gate.

Use fixed placeholders when masking fails, omit input-bearing parser and
masking exception diagnostics, and avoid applying execution hints while
preparing log text.

### Release note

Preserve SQL formatting in FE execution logs while masking recognized
credentials. Do not repeat the original SQL in syntax-error diagnostics.

### Check List (For Author)

- Test: FE Core compilation, 35 focused unit tests, and Checkstyle.
- Behavior changed: Yes; FE logs preserve layout and mask credential values.
  Audit log formatting and dispatch remain unchanged.
- Does this need documentation: No; no SQL or configuration interfaces change.
@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?

@gavinchou

Copy link
Copy Markdown
Contributor Author

run buildall

@gavinchou

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.

No new actionable findings in the seven-file diff at 6939795. The review converged after two rounds, with two reviewers covering the full change and a separate reviewer examining the identified risks. No existing inline findings require a blocking disposition. No additional user focus was supplied.

Critical checkpoint conclusions:

  1. Goal and evidence: value-only masking preserves source layout, converts code-point ranges for FE logging, and omits input-bearing parser diagnostics at the changed StmtExecutor boundaries. Added tests assert representative positive and negative behavior; they were inspected, not executed.
  2. Scope and reuse: changes remain focused and reuse existing sensitivity rules, property-key parsing, audit parser, and SQL rewriting.
  3. Concurrency and locks: no new threads, shared-state concurrency, lock acquisitions, or lock-order changes were introduced.
  4. Lifecycle: parser/maps are temporary; no new retained resources or static initialization dependencies. Inherited parsing can update statement IDs/aliases/hints, but no concrete new execution regression was established.
  5. Configuration: no configuration additions or dynamic-update requirements.
  6. Compatibility: the existing parser overload and audit gate/rendering mode remain available; no wire/storage format change.
  7. Thrift/protobuf: no definitions or field IDs changed.
  8. Parallel paths: reviewed preparse/parsed logging, retry, internal-query and HTTP planning paths, plus the separate audit dispatch.
  9. Conditions and errors: null/empty skips have concrete callers; sensitivity and layout checks match their purposes. Masking exceptions yield a fixed placeholder without exception text or Throwable.
  10. Test coverage: new JUnit cases cover exact layout, Unicode, hidden keys, password masking, CTAS/EXPLAIN, SET_VAR non-application, empty SQL, syntax errors and masking failures. Real retry/HTTP flows were not exercised end to end.
  11. Expected results: new assertions match the inspected grammar, policy and replacement spans; no generated regression result files changed.
  12. Observability: query identifiers and exception types remain available on the changed parser-error boundaries; no new operation needs metrics.
  13. Transactions/persistence: no transaction, EditLog, replay or failover logic changed.
  14. Writes/atomicity: no data-write or commit behavior changed; visibility and delete-bitmap invariants are unaffected.
  15. FE-BE state: no new cross-process variables or sending paths.
  16. Performance: UTF-16 conversion walks disjoint source spans linearly. Some logging paths add a masking parse, including retry/error arguments evaluated with DEBUG disabled; no substantiated material regression was found.
  17. Additional risks: normalized/escaped keys, duplicate-key failure behavior, disjoint password/property spans, supplementary characters, prepared placeholders, distribution hints and exception chains were rechecked. No unresolved new candidate remains.

Static review only: no builds or tests were run, as required. The new failure tests cover their exercised StmtExecutor logger boundaries. Pre-existing raw exception diagnostics in upstream/HTTP error paths remain; this result does not establish universal FE log sanitization. Audit behavior, including its existing limitations, is retained.

Review converged after 2 round(s).

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 70.18% (40/57) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17414	5130	5067	5067
q2	2134	313	292	292
q3	9999	1360	816	816
q4	4670	462	329	329
q5	7421	817	530	530
q6	206	188	155	155
q7	743	813	599	599
q8	9263	1297	1056	1056
q9	5707	4152	4179	4152
q10	6822	1286	1020	1020
q11	422	242	233	233
q12	639	393	278	278
q13	18100	3488	3014	3014
q14	273	265	244	244
q15	q16	720	703	675	675
q17	1174	759	575	575
q18	7046	6174	6095	6095
q19	1105	959	596	596
q20	387	352	226	226
q21	4986	2501	2535	2501
q22	365	335	275	275
Total cold run time: 99596 ms
Total hot run time: 28728 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5927	5822	5868	5822
q2	742	621	581	581
q3	5642	5661	5175	5175
q4	1995	2126	1559	1559
q5	5878	5619	5739	5619
q6	235	188	142	142
q7	2316	2052	1798	1798
q8	2994	2638	2627	2627
q9	7941	7436	7461	7436
q10	3660	3579	3155	3155
q11	574	412	378	378
q12	664	657	506	506
q13	3321	3585	2998	2998
q14	285	286	259	259
q15	q16	659	672	613	613
q17	7667	7038	6910	6910
q18	12983	12194	12866	12194
q19	895	766	786	766
q20	2135	2128	1926	1926
q21	5704	4679	4833	4679
q22	493	435	418	418
Total cold run time: 72710 ms
Total hot run time: 65561 ms

@hello-stephen

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

query5	4301	605	437	437
query6	427	208	189	189
query7	4794	452	226	226
query8	319	161	151	151
query9	8775	3050	3045	3045
query10	475	322	254	254
query11	6038	3849	3569	3569
query12	170	94	86	86
query13	1272	435	335	335
query14	6123	3919	3649	3649
query14_1	3438	3456	3381	3381
query15	203	192	173	173
query16	952	435	393	393
query17	851	633	500	500
query18	2414	412	296	296
query19	189	161	137	137
query20	82	87	80	80
query21	210	126	106	106
query22	12930	13035	12800	12800
query23	13373	12715	12423	12423
query23_1	12565	12479	12605	12479
query24	7316	804	448	448
query24_1	458	453	474	453
query25	505	385	339	339
query26	1254	251	133	133
query27	2774	437	267	267
query28	4588	1918	1933	1918
query29	1537	604	447	447
query30	305	222	184	184
query31	1016	924	818	818
query32	138	109	89	89
query33	534	305	249	249
query34	889	841	508	508
query35	777	745	652	652
query36	815	811	733	733
query37	126	99	83	83
query38	1747	1752	1668	1668
query39	793	793	740	740
query39_1	735	742	733	733
query40	225	118	96	96
query41	71	68	67	67
query42	86	85	85	85
query43	348	372	308	308
query44	1312	691	687	687
query45	197	177	174	174
query46	828	974	573	573
query47	3029	2989	2833	2833
query48	302	319	224	224
query49	586	404	295	295
query50	698	287	204	204
query51	10596	10368	10552	10368
query52	79	81	70	70
query53	188	212	155	155
query54	239	206	207	206
query55	77	70	65	65
query56	240	238	222	222
query57	1668	1629	1604	1604
query58	292	271	261	261
query59	2158	2151	1996	1996
query60	306	247	224	224
query61	166	165	165	165
query62	389	340	306	306
query63	189	161	161	161
query64	2849	1020	763	763
query65	3326	3285	3282	3282
query66	1771	415	293	293
query67	20203	20036	19953	19953
query68	2956	1032	604	604
query69	390	280	250	250
query70	849	787	782	782
query71	296	215	217	215
query72	2681	2562	2265	2265
query73	509	540	296	296
query74	4637	4505	4373	4373
query75	2346	2287	1920	1920
query76	2273	1014	582	582
query77	339	366	269	269
query78	9923	9643	9158	9158
query79	992	856	511	511
query80	1233	421	343	343
query81	589	314	278	278
query82	573	129	111	111
query83	302	206	187	187
query84	313	124	94	94
query85	858	422	366	366
query86	399	236	234	234
query87	2027	1980	1796	1796
query88	3738	2667	2657	2657
query89	331	280	240	240
query90	1847	166	167	166
query91	154	151	130	130
query92	96	91	91	91
query93	1061	1004	596	596
query94	638	287	271	271
query95	597	337	351	337
query96	661	486	230	230
query97	2476	2428	2331	2331
query98	162	154	148	148
query99	776	766	643	643
Total cold run time: 235396 ms
Total hot run time: 150639 ms

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.10	0.05	0.05
query3	0.27	0.09	0.09
query4	1.61	0.10	0.10
query5	0.23	0.24	0.25
query6	1.17	0.68	0.68
query7	0.03	0.01	0.00
query8	0.06	0.04	0.03
query9	0.40	0.35	0.35
query10	0.56	0.56	0.57
query11	0.20	0.15	0.15
query12	0.19	0.15	0.14
query13	0.49	0.49	0.48
query14	1.03	1.01	1.01
query15	0.62	0.60	0.60
query16	0.34	0.34	0.36
query17	1.18	1.15	1.13
query18	0.21	0.20	0.20
query19	2.10	1.94	2.05
query20	0.02	0.02	0.01
query21	15.48	0.18	0.13
query22	4.98	0.06	0.06
query23	16.29	0.33	0.12
query24	2.73	0.46	0.46
query25	0.12	0.07	0.05
query26	1.35	0.22	0.15
query27	0.05	0.05	0.06
query28	3.96	0.82	0.36
query29	12.47	4.12	3.20
query30	0.28	0.13	0.10
query31	2.77	0.54	0.32
query32	3.22	0.60	0.50
query33	3.24	3.15	3.25
query34	15.25	3.95	3.34
query35	3.35	3.32	3.33
query36	0.56	0.43	0.42
query37	0.08	0.06	0.07
query38	0.05	0.04	0.04
query39	0.03	0.02	0.02
query40	0.18	0.15	0.14
query41	0.08	0.02	0.02
query42	0.04	0.02	0.03
query43	0.04	0.04	0.03
Total cold run time: 97.42 s
Total hot run time: 24.17 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 1.07% (29/2710) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#69467

Problem Summary: The audit entry point uses the compact formatting mode,
but code-point-to-UTF-16 conversion only ran in the formatting-preserving
mode. Supplementary characters before or inside a credential could shift
the replacement range and leave part or all of its value unmasked.

Normalize replacement ranges at the NereidsParser.parseForEncryption
output boundary for both modes and for direct streaming callers. Collect
the original code-point ranges in sorted order and advance through them
once. Remove the mode-specific conversion from NeedAuditEncryption to
avoid converting the same range twice. Keep the existing audit rendering,
hidden-property policy and dispatch gate.

Add regressions for the default audit API, ASCII and BMP prefixes,
supplementary characters before and inside passwords, distinct output
policies, and multiple direct-parser replacement ranges.

### Release note

Correct credential masking for SQL containing supplementary Unicode
characters in audit and execution logs.

### Check List (For Author)

- Test: 58 focused FE unit tests and Checkstyle passed; FE Core compiled.
- Behavior changed: Yes; both formatting modes use correct UTF-16 ranges.
  Audit formatting and dispatch remain unchanged.
- Does this need documentation: No; no SQL or configuration interfaces change.
@gavinchou

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17590	5171	5055	5055
q2	2135	343	247	247
q3	10193	1403	812	812
q4	4679	461	336	336
q5	7444	794	522	522
q6	182	193	168	168
q7	771	800	587	587
q8	9261	1375	1093	1093
q9	5432	4197	4179	4179
q10	6836	1282	1059	1059
q11	421	252	230	230
q12	643	397	282	282
q13	18118	3694	3030	3030
q14	279	271	252	252
q15	q16	728	714	660	660
q17	1201	736	595	595
q18	7025	6202	6124	6124
q19	1114	967	602	602
q20	392	328	221	221
q21	5379	2465	2399	2399
q22	382	330	279	279
Total cold run time: 100205 ms
Total hot run time: 28732 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	6028	5884	6085	5884
q2	714	615	626	615
q3	5677	5875	5228	5228
q4	1996	2146	1547	1547
q5	5797	5859	5575	5575
q6	253	193	149	149
q7	2265	2073	1790	1790
q8	2990	2623	2665	2623
q9	7986	7556	7476	7476
q10	3609	3573	3117	3117
q11	576	417	406	406
q12	676	677	505	505
q13	3282	3611	3085	3085
q14	300	300	262	262
q15	q16	656	689	609	609
q17	7726	6977	6873	6873
q18	13020	12196	12907	12196
q19	893	770	795	770
q20	2175	2154	1924	1924
q21	5572	4562	4707	4562
q22	503	443	427	427
Total cold run time: 72694 ms
Total hot run time: 65623 ms

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17593	5402	5249	5249
q2	2140	324	251	251
q3	10219	1467	868	868
q4	4679	475	356	356
q5	7457	825	550	550
q6	206	211	165	165
q7	826	825	611	611
q8	9262	1514	1141	1141
q9	5661	4415	4413	4413
q10	6840	1325	1048	1048
q11	446	259	238	238
q12	646	424	299	299
q13	18073	3774	3056	3056
q14	277	277	243	243
q15	q16	726	719	670	670
q17	1344	768	577	577
q18	7088	6247	6195	6195
q19	1288	1105	634	634
q20	400	365	226	226
q21	5861	2501	2585	2501
q22	388	337	292	292
Total cold run time: 101420 ms
Total hot run time: 29583 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	6308	6169	6473	6169
q2	748	651	578	578
q3	5681	5887	5321	5321
q4	2069	2238	1578	1578
q5	6004	5599	5652	5599
q6	291	217	158	158
q7	2370	2011	1848	1848
q8	3137	2705	2705	2705
q9	7753	7506	7511	7506
q10	3670	3676	3208	3208
q11	599	425	398	398
q12	670	719	514	514
q13	3450	3707	3091	3091
q14	296	289	269	269
q15	q16	664	738	627	627
q17	7877	7154	6922	6922
q18	13007	12227	12833	12227
q19	1031	847	834	834
q20	2157	2152	1930	1930
q21	5849	4780	4925	4780
q22	506	480	442	442
Total cold run time: 74137 ms
Total hot run time: 66704 ms

@hello-stephen

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

query5	4317	596	454	454
query6	431	211	188	188
query7	4817	441	236	236
query8	319	172	153	153
query9	8785	3162	3170	3162
query10	474	322	263	263
query11	5985	3913	3579	3579
query12	150	91	85	85
query13	1243	433	334	334
query14	6152	3930	3657	3657
query14_1	3387	3476	3412	3412
query15	207	205	184	184
query16	961	422	397	397
query17	880	663	536	536
query18	2426	423	309	309
query19	209	165	135	135
query20	86	88	82	82
query21	210	127	108	108
query22	13030	13002	12739	12739
query23	13604	12897	12475	12475
query23_1	12470	12537	12446	12446
query24	7355	820	477	477
query24_1	472	473	468	468
query25	505	398	335	335
query26	1271	253	134	134
query27	2877	444	273	273
query28	4601	2036	2026	2026
query29	1545	588	440	440
query30	305	222	185	185
query31	1002	921	804	804
query32	149	88	89	88
query33	527	294	226	226
query34	900	857	501	501
query35	762	770	646	646
query36	816	812	728	728
query37	113	93	87	87
query38	1788	1720	1676	1676
query39	799	790	752	752
query39_1	739	722	734	722
query40	228	114	109	109
query41	83	81	78	78
query42	87	81	82	81
query43	339	366	319	319
query44	1304	704	721	704
query45	191	177	164	164
query46	831	967	571	571
query47	2777	2972	2923	2923
query48	295	308	214	214
query49	571	397	292	292
query50	667	281	211	211
query51	10362	10255	10523	10255
query52	79	87	69	69
query53	182	208	147	147
query54	238	196	218	196
query55	68	65	63	63
query56	245	218	222	218
query57	1646	1611	1562	1562
query58	296	274	265	265
query59	2223	2231	1974	1974
query60	294	238	227	227
query61	150	148	141	141
query62	387	331	288	288
query63	187	158	166	158
query64	2783	949	763	763
query65	3331	3283	3274	3274
query66	1782	407	304	304
query67	20228	20272	20040	20040
query68	3017	1016	623	623
query69	380	292	255	255
query70	859	784	817	784
query71	301	232	196	196
query72	2798	2627	2257	2257
query73	542	532	297	297
query74	4645	4505	4361	4361
query75	2348	2281	1946	1946
query76	2325	1024	594	594
query77	353	389	304	304
query78	9808	9770	9176	9176
query79	913	854	519	519
query80	468	418	340	340
query81	525	327	278	278
query82	208	129	109	109
query83	199	200	183	183
query84	297	118	94	94
query85	778	414	374	374
query86	289	241	235	235
query87	1973	1963	1839	1839
query88	3749	2774	2747	2747
query89	324	281	243	243
query90	2120	167	166	166
query91	169	156	131	131
query92	102	90	90	90
query93	997	990	580	580
query94	450	310	293	293
query95	584	323	311	311
query96	677	484	240	240
query97	2468	2434	2335	2335
query98	158	153	148	148
query99	758	770	657	657
Total cold run time: 233851 ms
Total hot run time: 151245 ms

@hello-stephen

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

query1	0.01	0.01	0.00
query2	0.09	0.05	0.05
query3	0.26	0.09	0.08
query4	1.61	0.09	0.10
query5	0.26	0.24	0.24
query6	1.17	0.68	0.69
query7	0.04	0.01	0.01
query8	0.05	0.04	0.03
query9	0.40	0.36	0.34
query10	0.58	0.57	0.61
query11	0.20	0.15	0.14
query12	0.18	0.15	0.14
query13	0.50	0.49	0.50
query14	1.03	1.00	1.01
query15	0.62	0.60	0.60
query16	0.34	0.36	0.35
query17	1.13	1.12	1.13
query18	0.20	0.20	0.18
query19	2.03	1.94	2.00
query20	0.02	0.01	0.02
query21	15.50	0.18	0.13
query22	5.06	0.06	0.06
query23	16.27	0.31	0.12
query24	3.08	0.50	0.30
query25	0.11	0.05	0.06
query26	0.84	0.24	0.15
query27	0.06	0.05	0.04
query28	2.70	0.76	0.37
query29	12.47	4.16	3.22
query30	0.30	0.13	0.10
query31	2.77	0.56	0.34
query32	3.23	0.59	0.50
query33	3.22	3.23	3.28
query34	15.21	4.00	3.35
query35	3.38	3.35	3.33
query36	0.56	0.44	0.43
query37	0.10	0.06	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.14	0.14
query41	0.09	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 96.02 s
Total hot run time: 24.14 s

@gavinchou
gavinchou merged commit dc02018 into apache:master Nov 23, 2026
52 of 53 checks passed
CalvinKirs added a commit to morningman/doris that referenced this pull request Nov 24, 2026
### Background

The pending always-on query audit change protects startup and runtime
settings and records prepared execution on the receiving FE.

### What problem does this PR solve?

Issue Number: None
Related PR: apache#70123 (local review follow-up), apache#69467 and apache#70366 (masking offset contracts)
PR Type: Bugfix

Problem Summary:

Close the review findings on early prepared redaction, invalid dispatcher
intervals, and audit records for rejected prepared handles. Keep audit
metadata separate from execution state, retain the audit file in always-on
mode, and use parser-provided UTF-16 ranges for audit text rewriting.

### Details

- Frequency: Applies to the affected prepared execution or logger paths, nonpositive dispatcher settings, and SQL masking with supplementary characters.
- Root cause: The earlier audit path lacked a saved redaction plan and skipped handle lookup failures. It used a one-sided interval bound and wrote the preparation hash into the live execution context. File logging used a shared switch. The shared masker converted offsets already normalized by the parser.
- Why existing tests missed it: Prepared audit tests exercised known handles and ordinary statements. The earlier focused run omitted the separate supplementary-character masking suite.
- Fix: Pass the saved plan and original template for sensitive execution, emit an event for an unknown handle, require a positive dispatcher interval, pass the hash into the audit event, keep the audit file appender, and give UTF-16 audit replacements an explicit rewrite entry point.
- Other paths and branches: Migrate streaming-insert masking consumers of the same parser offsets. Preserve lexer code-point handling for view rewrites. This commit targets the pending local PR branch.

### Testing

169 targeted FE tests passed in the expanded run. All 23 tests in the prepared-statement class passed after correcting its synthetic query ID fixture. Checkstyle passed on all 29 Java files in the full diff.

### Release note

Sensitive prepared audit records use masked SQL templates. Always-on query audit records unknown prepared handles, keeps its file appender, and rejects invalid dispatcher intervals. Audit SQL masking preserves supplementary characters correctly.

### Check List (For Author)

- Behavior changed: Yes (see Details).
- Does this need documentation: No separate update. The FE config description covers the audit file behavior.
- Pre-submission status: Partially verified: Docker and mixed-version cluster scenarios were not exercised.

### AI Disclosure

- Tool: Codex.
- Generated: Local bug fixes, unit coverage, and follow-up review.
- Human review: Pending.
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.

4 participants