Skip to content

Paimon reuse scanner#65404

Open
zhangstar333 wants to merge 3 commits into
apache:masterfrom
zhangstar333:paimon-reuse-scanner
Open

Paimon reuse scanner#65404
zhangstar333 wants to merge 3 commits into
apache:masterfrom
zhangstar333:paimon-reuse-scanner

Conversation

@zhangstar333

@zhangstar333 zhangstar333 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Problem Summary:
beore the PaimonJniReader handle multi splits one by one: eg:

PaimonJniReader(BE) ---> split1 ----> PaimonJniScanner(FE) -----> open -------> get_next-------->close.

split mapping to PaimonJniScanner, one split will new PaimonJniScanner object and deserialize, open, get_next, close.
so those will make JVM more pressure when have lost of splits.

now add reset logical, eg:
PaimonJniReader hold PaimonJniScanner not close it, when finish first split and reset some state, continue to handle next splits.

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?

@zhangstar333 zhangstar333 force-pushed the paimon-reuse-scanner branch from 17d7a1e to c273a9f Compare July 9, 2026 07:20
@zhangstar333

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.

Automated review found two blocking issues in the Paimon JNI scanner reuse.

Critical checkpoints:

  • Goal/test coverage: the scanner reuse is not complete because the legacy FileScanner Paimon JNI path still depends on constructor-provided paimon_split, and the new tests do not cover that path or close-failure cleanup.
  • Scope and parallel paths: the FileScannerV2 path was updated to call prepareForSplit, but the still-selectable legacy FileScanner path was not.
  • Lifecycle/error cleanup: PaimonJniReader::close can return before the base JNI cleanup when split reset fails.
  • Config/session propagation: the new paimon.jni.enable_file_reader_async option path was checked end to end; no additional issue found there.
  • Compatibility: mixed scanner implementations and the forwarded enable_file_scanner_v2 session variable make the legacy path a compatibility requirement.

Validation: static review plus git diff --check against base 64769a1. FE/BE tests were not run because this runner lacks thirdparty/installed and thirdparty/installed/bin/protoc.

Subagent conclusions: optimizer-rewrite OR-1 was merged into M-1; tests-session-config TSC-1 became M-2; convergence round 1 ended with both subagents reporting NO_NEW_VALUABLE_FINDINGS. User focus: no additional user-provided focus points.

@@ -132,7 +133,8 @@ public void open() throws IOException {
preExecutionAuthenticator.execute(() -> {
PaimonJdbcDriverUtils.registerDriverIfNeeded(params, classLoader);

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.

This breaks the legacy Paimon JNI reader path. open() no longer builds a reader from the constructor's paimon_split; it only initializes the table/projection and leaves reader null until prepareForSplit() runs. Format-v2 calls that new method, but the existing be/src/format/table/paimon_jni_reader.cpp path still passes paimon_split in the constructor params and then uses JniReader::open()/getNextBatchMeta() directly, with no prepareForSplit call. That path is still reachable whenever enable_file_scanner_v2=false (and for paths where v2 is not selected), so the first read hits Preconditions.checkState(reader != null, "Paimon split is not prepared") and the scan fails. Please keep backward compatibility by either preparing the constructor-provided split in open() when present, or teaching the legacy C++ reader to invoke prepareForSplit before reading.

return Status::OK();
}

Status PaimonJniReader::close() {

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.

close() should still run the base JNI cleanup even if resetting the current split reports an error. resetCurrentSplit() can throw when releasing an active batch or closing the Paimon reader, and Java close() is explicitly written to keep going with IOManager cleanup/metric accounting after that reset error. This C++ override returns immediately, so JniTableReader::close() never reaches the idempotent releaseTable() or Java close() call, and FileScannerV2::close() has already marked the scanner closed so it will not retry. Please preserve the first reset error but still attempt JniTableReader::close() before returning.

@zhangstar333 zhangstar333 force-pushed the paimon-reuse-scanner branch from 586b2f6 to 78de427 Compare July 14, 2026 10:00
@zhangstar333

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17630	4155	3996	3996
q2	2036	333	200	200
q3	10270	1477	832	832
q4	4690	473	340	340
q5	7500	845	568	568
q6	186	169	133	133
q7	790	840	629	629
q8	9348	1600	1635	1600
q9	5707	4333	4348	4333
q10	6751	1758	1469	1469
q11	497	347	324	324
q12	692	545	438	438
q13	18146	3402	2743	2743
q14	265	256	242	242
q15	q16	798	789	715	715
q17	992	886	970	886
q18	7067	5908	5583	5583
q19	1295	1270	1057	1057
q20	770	665	592	592
q21	5931	2678	2303	2303
q22	429	353	299	299
Total cold run time: 101790 ms
Total hot run time: 29282 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4324	4266	4270	4266
q2	294	328	237	237
q3	4591	4998	4423	4423
q4	2074	2337	1375	1375
q5	4407	4276	4270	4270
q6	223	175	124	124
q7	1691	1905	1910	1905
q8	2556	2170	2162	2162
q9	8000	8120	7751	7751
q10	4731	4729	4247	4247
q11	586	407	399	399
q12	767	776	566	566
q13	3276	3558	2997	2997
q14	311	305	274	274
q15	q16	716	725	624	624
q17	1356	1336	1351	1336
q18	7686	7327	7232	7232
q19	1173	1096	1105	1096
q20	2198	2217	1932	1932
q21	5276	4580	4434	4434
q22	529	470	414	414
Total cold run time: 56765 ms
Total hot run time: 52064 ms

@hello-stephen

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

query5	4318	634	488	488
query6	471	214	199	199
query7	4884	546	331	331
query8	335	184	167	167
query9	8755	4019	4069	4019
query10	488	361	302	302
query11	5927	2340	2159	2159
query12	160	105	102	102
query13	1269	624	435	435
query14	6265	5253	4893	4893
query14_1	4293	4284	4285	4284
query15	227	201	187	187
query16	1047	465	488	465
query17	1149	736	583	583
query18	2558	492	355	355
query19	216	193	153	153
query20	114	108	114	108
query21	232	163	136	136
query22	13573	13754	13409	13409
query23	17559	16600	16156	16156
query23_1	16260	16263	16234	16234
query24	7526	1745	1257	1257
query24_1	1284	1307	1272	1272
query25	598	502	362	362
query26	1304	367	209	209
query27	2598	589	366	366
query28	4424	1996	1990	1990
query29	1067	588	481	481
query30	333	260	240	240
query31	1121	1096	975	975
query32	106	61	59	59
query33	511	301	247	247
query34	1169	1136	664	664
query35	780	783	669	669
query36	1187	1185	1050	1050
query37	155	98	88	88
query38	1867	1707	1658	1658
query39	873	898	844	844
query39_1	823	825	829	825
query40	243	166	137	137
query41	65	62	64	62
query42	93	90	90	90
query43	321	321	279	279
query44	1436	767	753	753
query45	188	184	169	169
query46	1094	1262	702	702
query47	2165	2084	2015	2015
query48	387	431	295	295
query49	581	434	309	309
query50	1023	406	328	328
query51	10537	10667	10433	10433
query52	92	86	72	72
query53	252	280	199	199
query54	301	225	212	212
query55	73	71	69	69
query56	281	296	265	265
query57	1337	1308	1206	1206
query58	288	254	259	254
query59	1546	1622	1446	1446
query60	300	277	247	247
query61	147	148	184	148
query62	540	497	426	426
query63	243	203	199	199
query64	2828	1042	858	858
query65	4708	4658	4637	4637
query66	1803	497	374	374
query67	29388	29267	29164	29164
query68	3094	1478	972	972
query69	410	302	275	275
query70	1086	959	930	930
query71	354	312	292	292
query72	3059	2712	2525	2525
query73	794	736	422	422
query74	5066	4916	4721	4721
query75	2528	2491	2134	2134
query76	2343	1167	807	807
query77	346	378	290	290
query78	11936	11923	11217	11217
query79	1351	1139	717	717
query80	742	543	428	428
query81	468	318	273	273
query82	564	156	118	118
query83	395	327	300	300
query84	285	156	132	132
query85	950	591	497	497
query86	405	314	259	259
query87	1823	1811	1740	1740
query88	3672	2804	2779	2779
query89	435	373	327	327
query90	1818	199	201	199
query91	197	188	162	162
query92	66	58	55	55
query93	1582	1456	1009	1009
query94	602	368	302	302
query95	787	479	478	478
query96	1102	772	338	338
query97	2634	2611	2505	2505
query98	209	213	203	203
query99	1124	1101	967	967
Total cold run time: 262222 ms
Total hot run time: 177652 ms

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.09	0.06	0.05
query3	0.26	0.14	0.14
query4	1.62	0.16	0.15
query5	0.24	0.22	0.22
query6	1.26	1.07	1.06
query7	0.04	0.01	0.01
query8	0.05	0.04	0.04
query9	0.39	0.33	0.32
query10	0.54	0.54	0.54
query11	0.20	0.14	0.14
query12	0.18	0.15	0.15
query13	0.48	0.49	0.48
query14	1.01	1.02	1.02
query15	0.63	0.59	0.61
query16	0.31	0.34	0.31
query17	1.08	1.08	1.10
query18	0.23	0.22	0.21
query19	2.07	1.92	1.96
query20	0.02	0.01	0.01
query21	15.44	0.22	0.14
query22	4.87	0.05	0.05
query23	16.13	0.31	0.12
query24	2.99	0.42	0.30
query25	0.12	0.04	0.04
query26	0.75	0.21	0.14
query27	0.04	0.03	0.04
query28	3.51	0.95	0.54
query29	12.53	4.02	3.20
query30	0.28	0.16	0.16
query31	2.76	0.60	0.31
query32	3.24	0.60	0.49
query33	3.22	3.16	3.26
query34	15.63	4.27	3.50
query35	3.56	3.54	3.51
query36	0.55	0.44	0.41
query37	0.10	0.06	0.07
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.17	0.17
query41	0.09	0.04	0.03
query42	0.04	0.03	0.03
query43	0.05	0.04	0.04
Total cold run time: 96.88 s
Total hot run time: 24.95 s

@zhangstar333

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17671	4098	4090	4090
q2	2029	318	198	198
q3	10273	1506	837	837
q4	4717	474	335	335
q5	7660	847	576	576
q6	197	172	141	141
q7	751	837	613	613
q8	10316	1621	1564	1564
q9	5996	4406	4316	4316
q10	6791	1767	1451	1451
q11	499	351	302	302
q12	712	574	419	419
q13	18111	3333	2794	2794
q14	261	268	245	245
q15	q16	782	771	713	713
q17	993	1071	905	905
q18	7050	5746	5479	5479
q19	1219	1276	1116	1116
q20	774	660	568	568
q21	5532	2607	2393	2393
q22	437	357	297	297
Total cold run time: 102771 ms
Total hot run time: 29352 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4357	4250	4267	4250
q2	290	314	214	214
q3	4567	4972	4455	4455
q4	2058	2146	1360	1360
q5	4425	4277	4251	4251
q6	217	173	124	124
q7	1750	2100	1649	1649
q8	2517	2184	2065	2065
q9	7731	7692	7720	7692
q10	4704	4618	4193	4193
q11	573	426	390	390
q12	733	752	547	547
q13	3523	3643	2928	2928
q14	300	299	279	279
q15	q16	746	756	629	629
q17	1350	1310	1348	1310
q18	8026	7196	6968	6968
q19	1075	1061	1062	1061
q20	2202	2208	1936	1936
q21	5239	4536	4415	4415
q22	510	445	406	406
Total cold run time: 56893 ms
Total hot run time: 51122 ms

@hello-stephen

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

query5	4321	618	475	475
query6	474	222	210	210
query7	4945	611	320	320
query8	355	189	182	182
query9	8749	4087	4081	4081
query10	482	359	302	302
query11	5861	2334	2144	2144
query12	166	106	100	100
query13	1260	609	432	432
query14	6261	5209	4894	4894
query14_1	4265	4256	4269	4256
query15	219	210	188	188
query16	1014	476	441	441
query17	969	731	588	588
query18	2494	493	347	347
query19	210	195	153	153
query20	113	108	112	108
query21	240	166	137	137
query22	13578	13677	13338	13338
query23	17331	16441	16035	16035
query23_1	16285	16226	16224	16224
query24	7559	1751	1277	1277
query24_1	1308	1313	1273	1273
query25	591	482	393	393
query26	1353	360	211	211
query27	2579	582	379	379
query28	4466	2006	1988	1988
query29	1144	610	509	509
query30	342	262	221	221
query31	1125	1087	965	965
query32	112	63	65	63
query33	528	322	270	270
query34	1169	1137	630	630
query35	765	806	673	673
query36	1184	1190	1095	1095
query37	153	104	92	92
query38	1882	1698	1669	1669
query39	895	890	848	848
query39_1	835	841	832	832
query40	246	214	139	139
query41	69	63	62	62
query42	92	91	91	91
query43	326	322	281	281
query44	1411	763	761	761
query45	193	180	173	173
query46	1053	1234	693	693
query47	2163	2102	2019	2019
query48	418	396	281	281
query49	578	421	306	306
query50	1046	401	340	340
query51	10653	10975	10600	10600
query52	84	85	74	74
query53	260	267	199	199
query54	286	224	214	214
query55	74	70	67	67
query56	289	289	277	277
query57	1313	1277	1203	1203
query58	282	263	270	263
query59	1548	1622	1446	1446
query60	299	276	255	255
query61	156	154	151	151
query62	562	492	433	433
query63	239	202	209	202
query64	2825	1056	911	911
query65	4709	4629	4599	4599
query66	1862	509	376	376
query67	29308	29214	28415	28415
query68	3167	1503	969	969
query69	411	291	263	263
query70	1044	961	962	961
query71	350	317	348	317
query72	3074	2622	2402	2402
query73	796	750	425	425
query74	5075	4931	4723	4723
query75	2508	2485	2218	2218
query76	2343	1164	786	786
query77	364	374	293	293
query78	11834	11822	11452	11452
query79	1517	1098	760	760
query80	1296	553	461	461
query81	524	323	276	276
query82	610	155	121	121
query83	369	311	300	300
query84	327	158	134	134
query85	959	593	533	533
query86	429	303	278	278
query87	1829	1820	1759	1759
query88	3687	2784	2809	2784
query89	440	369	327	327
query90	1887	195	193	193
query91	203	194	163	163
query92	66	59	57	57
query93	1820	1557	919	919
query94	728	359	331	331
query95	781	493	548	493
query96	1037	809	364	364
query97	2649	2618	2491	2491
query98	222	213	200	200
query99	1077	1112	967	967
Total cold run time: 263714 ms
Total hot run time: 176910 ms

@hello-stephen

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

query1	0.00	0.00	0.01
query2	0.11	0.05	0.04
query3	0.25	0.14	0.13
query4	1.60	0.14	0.13
query5	0.25	0.25	0.21
query6	1.27	1.10	1.07
query7	0.04	0.00	0.00
query8	0.06	0.04	0.04
query9	0.38	0.31	0.31
query10	0.56	0.57	0.56
query11	0.19	0.14	0.13
query12	0.18	0.14	0.14
query13	0.48	0.48	0.46
query14	1.01	1.00	1.00
query15	0.62	0.58	0.59
query16	0.33	0.31	0.31
query17	1.06	1.09	1.10
query18	0.22	0.20	0.20
query19	2.06	1.93	2.00
query20	0.02	0.01	0.02
query21	15.46	0.20	0.13
query22	4.98	0.05	0.06
query23	16.11	0.31	0.12
query24	3.00	0.41	0.30
query25	0.11	0.06	0.04
query26	0.74	0.20	0.16
query27	0.05	0.04	0.04
query28	3.48	0.89	0.52
query29	12.50	4.13	3.24
query30	0.28	0.15	0.16
query31	2.77	0.61	0.31
query32	3.22	0.59	0.48
query33	3.16	3.22	3.16
query34	15.59	4.20	3.54
query35	3.48	3.49	3.51
query36	0.54	0.40	0.41
query37	0.09	0.06	0.06
query38	0.05	0.03	0.04
query39	0.03	0.04	0.03
query40	0.18	0.17	0.16
query41	0.09	0.03	0.03
query42	0.04	0.02	0.02
query43	0.04	0.03	0.04
Total cold run time: 96.68 s
Total hot run time: 24.83 s

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.

2 participants