Skip to content

[fix](load) fix load_to_single_tablet routing for auto partition#64356

Open
sollhui wants to merge 1 commit into
apache:masterfrom
sollhui:fix_auto_partition_tablet_index
Open

[fix](load) fix load_to_single_tablet routing for auto partition#64356
sollhui wants to merge 1 commit into
apache:masterfrom
sollhui:fix_auto_partition_tablet_index

Conversation

@sollhui

@sollhui sollhui commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

load_tablet_idx is used by random distribution routing. For normal random
loads it can advance across batches, but for load_to_single_tablet=true it
must remain fixed for the partition in the sink so all rows are routed to one
tablet.

For normally planned partitions this is stable because FE builds the sink plan
once and all BE sink instances receive the same load_tablet_idx.

For runtime auto partitions, each BE can independently call createPartition()
or replacePartition() for the same txn and partition. Before this patch, the
auto partition cache only stored tablet locations and did not store
load_tablet_idx. FE also did not know whether the caller was using
load_to_single_tablet, so runtime auto partitions could lose the single-tablet
routing semantics or compute different tablet indexes across BE RPCs.

This patch passes load_to_single_tablet in create/replace partition RPCs and
stores the selected load_tablet_idx in AutoPartitionCacheManager. Later BE
RPCs for the same txn and partition reuse the cached tablet index together with
the cached tablet locations. Ordinary random loads are unchanged.

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

sollhui added a commit to sollhui/doris that referenced this pull request Jun 10, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64356

Problem Summary: Resolve the PR merge conflict with current master while preserving the load_to_single_tablet auto partition load tablet index cache fix and the latest master cloud tablet location lookup logic.

### Release note

None

### Check List (For Author)

- Test: ./build-support/check-format.sh; ./run-fe-ut.sh --run org.apache.doris.transaction.AutoPartitionCacheManagerTest (failed before running the target test because fe-catalog does not compile on current workspace/master: Column.java TPatternType conversion and missing ScalarType variant methods)
- Behavior changed: No
- Does this need documentation: No
@sollhui

sollhui commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

/review

@sollhui

sollhui commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

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

I found a compile-blocking issue.

Critical checkpoint conclusions:

  • Goal/test: The PR intends to preserve load_tablet_idx for runtime auto partitions when load_to_single_tablet=true. The implementation shape addresses the right create/replace RPC and cache paths, and adds a cache unit test, but the FE code cannot compile in its current form.
  • Scope/focus: The change is small and focused on BE request propagation, FE response construction, and the auto-partition cache.
  • Concurrency/lifecycle: The new cached primitive shares the existing ConcurrentHashMap entry and transaction cleanup lifecycle; I did not find a new lock-order or lifecycle issue.
  • Config/compatibility: No config item is added. The Thrift request fields are optional with default false, so the protocol change is structurally compatible.
  • Parallel paths: Both createPartition and replacePartition runtime paths are updated, and both BE writer paths use the shared VRowDistribution request code.
  • Tests/results: A unit test covers AutoPartitionCacheManager returning the cached index, but I did not run the FE test because the missing import is already a compile blocker.
  • Observability/performance/persistence: No additional issue found; the cache remains in-memory transaction-scoped state and does not add persistence requirements.
  • User focus: No additional user-provided focus was supplied.

Please fix the missing import and rerun the relevant FE/BE checks.

sollhui added a commit to sollhui/doris that referenced this pull request Jun 10, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64356

Problem Summary: Fix FE compile errors after resolving conflicts for the auto partition load tablet index change. FrontendServiceImpl now imports DistributionInfo explicitly, and the cached load tablet index path uses long/AtomicLong to match TOlapTablePartition.load_tablet_idx, which is thrift i64.

### Release note

None

### Check List (For Author)

- Test: git diff --check; ./run-fe-ut.sh --run org.apache.doris.transaction.AutoPartitionCacheManagerTest (blocked before running target test by existing fe-catalog compile errors in local workspace: Column.java TPatternType conversion and missing ScalarType variant methods)
- Behavior changed: No
- Does this need documentation: No
@sollhui sollhui force-pushed the fix_auto_partition_tablet_index branch from 0332b6e to 1b03e7e Compare June 10, 2026 06:42
@sollhui

sollhui commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@sollhui

sollhui commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

/review

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 78.39% (1915/2443)
Line Coverage 64.89% (34211/52725)
Region Coverage 65.31% (17599/26948)
Branch Coverage 53.99% (9349/17316)

@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 result: no additional blocking issues found in this pass. The existing inline thread about the missing DistributionInfo import is already-known review context, and the current head includes that import, so I did not duplicate it.

Critical checkpoint conclusions:

  • Goal and proof: The PR passes load_to_single_tablet from BE auto-partition RPCs and persists the selected loadTabletIdx in AutoPartitionCacheManager so concurrent create/replace calls for the same txn/partition reuse the same tablet index. The added unit test covers cache reuse of the index; no end-to-end auto-partition load test is added.
  • Scope: The change is small and focused across the BE RPC request construction, FE RPC handling/cache, thrift request fields, and one FE unit test.
  • Concurrency: The new cached value follows the existing ConcurrentHashMap cache path. The first writer wins through computeIfAbsent, later callers receive the cached tablet locations and cached loadTabletIdx. I did not find a new lock-order or heavy-work-under-lock issue.
  • Lifecycle: The added value has the same txn-scoped lifecycle as cached tablet locations and is cleared by the existing transaction finish/abort cleanup paths in local and cloud transaction managers.
  • Configuration and compatibility: No config or storage format changes. The new thrift fields are optional with default false; older callers preserve previous behavior.
  • Parallel paths: Both createPartition and replacePartition, plus both BE automatic create and overwrite replace request paths, are updated.
  • Conditional/error handling: The loadTabletIdx is only attached for load_to_single_tablet on random distribution partitions, and UserException from the recorder is converted to RPC status like adjacent code.
  • Transaction/data correctness: I did not find a visibility, commit, or atomicity regression; cache keying remains txn id plus partition id.
  • Performance and observability: Added work is O(partitions) with one recorder lookup only for the targeted mode; existing debug logging is extended for the cached index.
  • Tests: I attempted ./run-fe-ut.sh --run org.apache.doris.transaction.AutoPartitionCacheManagerTest, but this runner is missing thirdparty/installed/bin/protoc, so generated-source setup failed before the test could compile or run.
  • User focus: review_focus.txt contains no additional focus points.

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 78.39% (1915/2443)
Line Coverage 64.89% (34212/52725)
Region Coverage 65.33% (17605/26948)
Branch Coverage 54.02% (9354/17316)

@hello-stephen

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

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17682	3998	3928	3928
q2	q3	11140	1474	942	942
q4	4755	482	347	347
q5	8586	878	590	590
q6	365	174	138	138
q7	960	853	623	623
q8	11007	1602	1641	1602
q9	7167	4584	4522	4522
q10	6852	1837	1545	1545
q11	443	278	252	252
q12	648	438	304	304
q13	18165	3378	2816	2816
q14	270	261	239	239
q15	q16	818	778	713	713
q17	932	974	875	875
q18	7035	5726	5512	5512
q19	1173	1335	1256	1256
q20	586	468	297	297
q21	6035	2967	2677	2677
q22	457	386	324	324
Total cold run time: 105076 ms
Total hot run time: 29502 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	4698	4714	4685	4685
q2	q3	5004	5337	4598	4598
q4	2104	2214	1387	1387
q5	5009	4637	4851	4637
q6	236	182	130	130
q7	1894	1719	1579	1579
q8	2455	2176	2068	2068
q9	7547	7435	7430	7430
q10	4773	4702	4244	4244
q11	538	405	354	354
q12	744	737	527	527
q13	3153	3410	2823	2823
q14	267	286	252	252
q15	q16	672	696	618	618
q17	1296	1259	1270	1259
q18	7470	6711	6738	6711
q19	1126	1096	1090	1090
q20	2218	2233	1949	1949
q21	5295	4622	4445	4445
q22	540	468	408	408
Total cold run time: 57039 ms
Total hot run time: 51194 ms

@hello-stephen

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

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17656	4052	4075	4052
q2	q3	10768	1441	809	809
q4	4682	483	351	351
q5	7550	895	601	601
q6	184	174	145	145
q7	794	836	640	640
q8	9357	1589	1730	1589
q9	5885	4651	4560	4560
q10	6768	1848	1546	1546
q11	440	290	262	262
q12	634	431	317	317
q13	18121	3454	2845	2845
q14	273	259	239	239
q15	q16	790	783	712	712
q17	1015	990	911	911
q18	6930	5769	5599	5599
q19	1144	1268	1087	1087
q20	530	411	263	263
q21	6268	2942	2793	2793
q22	464	381	339	339
Total cold run time: 100253 ms
Total hot run time: 29660 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	5091	4828	4660	4660
q2	q3	4840	5308	4672	4672
q4	2132	2202	1420	1420
q5	4906	4974	4672	4672
q6	232	178	126	126
q7	1859	1867	1569	1569
q8	2485	2139	2216	2139
q9	7993	7776	7410	7410
q10	4799	4712	4267	4267
q11	540	385	359	359
q12	740	750	532	532
q13	3080	3428	2738	2738
q14	289	280	253	253
q15	q16	688	705	621	621
q17	1302	1278	1278	1278
q18	7384	6752	6869	6752
q19	1124	1138	1123	1123
q20	2222	2240	1951	1951
q21	5358	4701	4537	4537
q22	528	476	419	419
Total cold run time: 57592 ms
Total hot run time: 51498 ms

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 13.46% (7/52) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

query5	4368	642	479	479
query6	566	213	187	187
query7	4845	526	309	309
query8	408	228	202	202
query9	8832	4012	3984	3984
query10	447	313	254	254
query11	5852	2369	2211	2211
query12	164	100	96	96
query13	1272	615	419	419
query14	6415	5482	5094	5094
query14_1	4439	4398	4400	4398
query15	220	202	182	182
query16	1039	479	467	467
query17	1143	741	619	619
query18	2729	504	362	362
query19	227	191	152	152
query20	122	112	106	106
query21	224	142	120	120
query22	13634	13646	13467	13467
query23	17473	16504	16202	16202
query23_1	16230	16311	16333	16311
query24	7597	1776	1276	1276
query24_1	1341	1317	1320	1317
query25	545	465	424	424
query26	1314	329	169	169
query27	2604	583	335	335
query28	4446	2005	2011	2005
query29	1057	598	481	481
query30	338	242	198	198
query31	1115	1080	946	946
query32	105	61	58	58
query33	518	321	251	251
query34	1225	1151	644	644
query35	757	777	678	678
query36	1374	1399	1281	1281
query37	166	104	91	91
query38	3206	3161	3066	3066
query39	980	921	901	901
query39_1	883	882	873	873
query40	217	123	100	100
query41	66	66	65	65
query42	96	93	96	93
query43	321	323	278	278
query44	
query45	199	185	184	184
query46	1071	1179	747	747
query47	2390	2415	2314	2314
query48	409	413	284	284
query49	643	478	352	352
query50	970	349	271	271
query51	4333	4309	4243	4243
query52	86	87	76	76
query53	256	261	189	189
query54	270	231	193	193
query55	76	77	70	70
query56	231	232	210	210
query57	1446	1399	1317	1317
query58	263	217	201	201
query59	1601	1640	1446	1446
query60	279	248	234	234
query61	163	162	159	159
query62	720	655	589	589
query63	228	186	189	186
query64	2593	785	664	664
query65	
query66	1733	466	353	353
query67	29943	29716	29669	29669
query68	
query69	429	316	266	266
query70	958	953	970	953
query71	313	219	211	211
query72	3030	2727	1983	1983
query73	848	759	433	433
query74	5121	5000	4774	4774
query75	2674	2600	2257	2257
query76	2308	1145	788	788
query77	352	377	285	285
query78	12560	12437	11852	11852
query79	1298	1012	763	763
query80	601	495	395	395
query81	451	282	245	245
query82	342	156	125	125
query83	364	275	252	252
query84	
query85	940	529	440	440
query86	372	303	283	283
query87	3403	3362	3189	3189
query88	3678	2750	2710	2710
query89	420	385	326	326
query90	1909	173	177	173
query91	185	163	137	137
query92	63	62	52	52
query93	1462	1437	905	905
query94	562	363	336	336
query95	692	400	440	400
query96	1083	814	336	336
query97	2684	2732	2578	2578
query98	221	216	208	208
query99	1189	1196	1062	1062
Total cold run time: 251787 ms
Total hot run time: 169075 ms

@hello-stephen

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

query5	4324	654	490	490
query6	459	206	189	189
query7	4824	565	327	327
query8	384	224	209	209
query9	8801	4047	4051	4047
query10	447	326	264	264
query11	5909	2384	2135	2135
query12	164	104	107	104
query13	1256	643	411	411
query14	6441	5419	5098	5098
query14_1	4448	4407	4341	4341
query15	203	203	175	175
query16	1013	453	454	453
query17	1098	697	570	570
query18	2443	469	339	339
query19	203	178	139	139
query20	111	106	107	106
query21	215	137	119	119
query22	13663	13498	13470	13470
query23	17324	16600	16225	16225
query23_1	16302	16321	16347	16321
query24	7644	1765	1313	1313
query24_1	1318	1308	1311	1308
query25	555	436	372	372
query26	1320	329	166	166
query27	2647	580	354	354
query28	4496	2017	2032	2017
query29	1074	623	497	497
query30	312	236	203	203
query31	1126	1093	964	964
query32	112	66	63	63
query33	531	336	274	274
query34	1220	1209	655	655
query35	765	793	690	690
query36	1413	1438	1277	1277
query37	157	114	93	93
query38	3222	3162	3064	3064
query39	942	925	898	898
query39_1	874	896	878	878
query40	228	131	109	109
query41	76	68	69	68
query42	99	98	98	98
query43	326	333	288	288
query44	
query45	200	194	187	187
query46	1116	1240	779	779
query47	2367	2440	2336	2336
query48	397	432	282	282
query49	681	473	353	353
query50	988	345	255	255
query51	4308	4292	4215	4215
query52	88	90	78	78
query53	240	264	188	188
query54	274	219	194	194
query55	77	76	71	71
query56	229	221	232	221
query57	1442	1443	1342	1342
query58	250	238	217	217
query59	1583	1625	1471	1471
query60	285	246	235	235
query61	163	155	158	155
query62	696	645	581	581
query63	236	182	201	182
query64	2522	790	641	641
query65	
query66	1792	464	343	343
query67	29852	29656	29641	29641
query68	
query69	433	304	266	266
query70	1077	1040	989	989
query71	328	226	220	220
query72	3023	2706	2550	2550
query73	839	788	419	419
query74	5124	5004	4757	4757
query75	2684	2596	2268	2268
query76	2353	1183	766	766
query77	354	394	294	294
query78	12467	12480	11942	11942
query79	1486	1021	777	777
query80	590	471	388	388
query81	452	280	245	245
query82	566	161	124	124
query83	355	272	249	249
query84	
query85	895	536	450	450
query86	363	286	291	286
query87	3406	3320	3252	3252
query88	3610	2718	2722	2718
query89	420	385	328	328
query90	2009	184	179	179
query91	180	170	148	148
query92	66	63	61	61
query93	1454	1403	900	900
query94	553	353	331	331
query95	700	474	347	347
query96	1021	779	333	333
query97	2727	2681	2585	2585
query98	209	214	201	201
query99	1170	1163	1092	1092
Total cold run time: 251576 ms
Total hot run time: 170573 ms

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