Skip to content

[fix](partition) fix table version not updated after replacing temp partition#60888

Open
sollhui wants to merge 2 commits intoapache:masterfrom
sollhui:fix_replace_tmp_partition
Open

[fix](partition) fix table version not updated after replacing temp partition#60888
sollhui wants to merge 2 commits intoapache:masterfrom
sollhui:fix_replace_tmp_partition

Conversation

@sollhui
Copy link
Contributor

@sollhui sollhui commented Feb 27, 2026

Summary

After executing ALTER TABLE ... REPLACE PARTITION ... WITH TEMPORARY PARTITION,
queries on the replaced partition may return empty results due to stale sorted
partition cache.

Root Cause

In Env.replaceTempPartition(), the table version update is conditionally skipped
in non-cloud mode with the comment claiming "the internal partition deletion logic
will update the table version in cloud mode". However, tracing the call chain:

  • OlapTable.replaceTempPartitions()dropPartition()dropPartitionCommon()
    CatalogRecycleBin.recyclePartition()

None of these methods update the table version. This means after replacing a temp
partition, the table version remains unchanged, and the sorted partition cache is
not invalidated.

The same issue exists in replayReplaceTempPartition() on follower FEs.

Fix

Remove the Config.isNotCloudMode() guard so that table version is always updated
after replacing temp partitions, in both replaceTempPartition() and
replayReplaceTempPartition().

How to Reproduce

  1. Create a table with a range partition
  2. Add a temporary partition with the same range
  3. Insert data into the temporary partition
  4. Wait for sorted partition cache to populate (~10s)
  5. Query the table (returns 0 rows from the empty original partition, populating cache)
  6. Replace the partition with the temporary partition
  7. Query again — returns 0 rows (stale cache) instead of the expected 1 row

@Thearas
Copy link
Contributor

Thearas commented Feb 27, 2026

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
Copy link
Contributor Author

sollhui commented Feb 27, 2026

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
============================================
q1	17646	4457	4265	4265
q2	q3	10657	772	517	517
q4	4677	363	257	257
q5	7567	1190	1004	1004
q6	178	178	149	149
q7	762	841	672	672
q8	9296	1454	1329	1329
q9	4788	4718	4651	4651
q10	6812	1867	1612	1612
q11	460	253	258	253
q12	710	617	471	471
q13	17774	4197	3410	3410
q14	224	229	220	220
q15	966	800	783	783
q16	738	720	670	670
q17	718	896	391	391
q18	6155	5324	5197	5197
q19	1319	983	622	622
q20	501	498	384	384
q21	4828	1862	1384	1384
q22	340	290	241	241
Total cold run time: 97116 ms
Total hot run time: 28482 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4406	4341	4332	4332
q2	q3	1760	2161	1715	1715
q4	839	1175	763	763
q5	4027	4271	4342	4271
q6	177	175	143	143
q7	1814	1605	1454	1454
q8	2400	2645	2532	2532
q9	7469	7423	7470	7423
q10	2782	2949	2432	2432
q11	514	452	428	428
q12	506	603	448	448
q13	3960	4543	3648	3648
q14	287	305	286	286
q15	850	822	808	808
q16	722	766	719	719
q17	1171	1572	1295	1295
q18	7079	6850	6734	6734
q19	930	915	976	915
q20	2134	2150	2026	2026
q21	3933	3552	3453	3453
q22	455	420	399	399
Total cold run time: 48215 ms
Total hot run time: 46224 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 182915 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 d9d2b58b32dbadf8a955e7824a1ac4a19dc1b0f4, data reload: false

query5	4809	654	513	513
query6	322	225	214	214
query7	4212	466	263	263
query8	339	252	249	249
query9	8729	2743	2690	2690
query10	549	380	348	348
query11	17052	17446	17052	17052
query12	194	147	125	125
query13	2721	482	356	356
query14	6694	3356	3038	3038
query14_1	2961	3003	2899	2899
query15	213	198	181	181
query16	1044	481	393	393
query17	1662	842	620	620
query18	2801	447	377	377
query19	204	206	180	180
query20	141	136	143	136
query21	211	142	124	124
query22	5263	4839	4732	4732
query23	17138	16789	16514	16514
query23_1	16598	16623	16731	16623
query24	7223	1620	1224	1224
query24_1	1212	1244	1242	1242
query25	535	446	435	435
query26	1237	260	154	154
query27	2777	476	291	291
query28	4468	1862	1873	1862
query29	809	551	463	463
query30	322	242	214	214
query31	900	725	656	656
query32	82	71	69	69
query33	527	330	270	270
query34	921	908	557	557
query35	633	663	591	591
query36	1108	1112	921	921
query37	134	97	84	84
query38	2992	2886	2891	2886
query39	984	854	849	849
query39_1	831	832	799	799
query40	229	147	133	133
query41	63	59	59	59
query42	108	101	101	101
query43	377	376	356	356
query44	
query45	196	196	184	184
query46	879	982	601	601
query47	2073	2122	2050	2050
query48	313	315	232	232
query49	624	466	369	369
query50	686	270	212	212
query51	4158	4130	4062	4062
query52	106	108	94	94
query53	285	335	287	287
query54	294	262	300	262
query55	96	84	81	81
query56	313	319	313	313
query57	1368	1320	1272	1272
query58	288	278	271	271
query59	2568	2641	2490	2490
query60	323	340	329	329
query61	150	140	143	140
query62	613	597	529	529
query63	303	279	271	271
query64	4836	1263	1082	1082
query65	
query66	1412	500	381	381
query67	16229	16363	16186	16186
query68	
query69	395	336	308	308
query70	983	981	953	953
query71	344	310	315	310
query72	2923	2744	2414	2414
query73	549	536	324	324
query74	10026	9930	9730	9730
query75	2846	2746	2460	2460
query76	2315	1058	691	691
query77	373	377	311	311
query78	11182	11374	10647	10647
query79	1135	810	601	601
query80	1349	610	536	536
query81	564	290	243	243
query82	1025	153	116	116
query83	349	255	243	243
query84	246	122	100	100
query85	899	500	425	425
query86	416	317	296	296
query87	3111	3088	2984	2984
query88	3594	2693	2666	2666
query89	427	373	346	346
query90	2033	176	178	176
query91	163	156	126	126
query92	83	79	68	68
query93	917	841	508	508
query94	633	325	307	307
query95	603	405	327	327
query96	626	524	231	231
query97	2474	2506	2372	2372
query98	238	216	221	216
query99	1012	992	916	916
Total cold run time: 255689 ms
Total hot run time: 182915 ms

@sollhui sollhui force-pushed the fix_replace_tmp_partition branch from d9d2b58 to 8419725 Compare February 28, 2026 02:20
@sollhui
Copy link
Contributor Author

sollhui commented Feb 28, 2026

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
============================================
q1	17689	4647	4322	4322
q2	q3	10642	780	521	521
q4	4683	345	251	251
q5	7552	1201	1013	1013
q6	169	173	145	145
q7	766	827	663	663
q8	9294	1448	1306	1306
q9	4922	4787	4684	4684
q10	6821	1876	1662	1662
q11	462	263	233	233
q12	726	570	470	470
q13	17791	4257	3445	3445
q14	229	227	216	216
q15	924	787	794	787
q16	751	726	667	667
q17	722	878	417	417
q18	6046	5361	5174	5174
q19	1157	958	605	605
q20	495	488	379	379
q21	4762	1954	1433	1433
q22	355	335	264	264
Total cold run time: 96958 ms
Total hot run time: 28657 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4716	4647	4514	4514
q2	q3	1814	2277	1772	1772
q4	874	1211	790	790
q5	4032	4374	4330	4330
q6	183	174	138	138
q7	1746	1625	1534	1534
q8	2469	2698	2574	2574
q9	7430	7292	7422	7292
q10	2642	2817	2385	2385
q11	500	439	410	410
q12	498	595	453	453
q13	4061	4420	3543	3543
q14	284	296	338	296
q15	953	867	829	829
q16	718	781	724	724
q17	1151	1537	1341	1341
q18	7082	6735	6605	6605
q19	869	862	867	862
q20	2095	2158	1967	1967
q21	3925	3420	3438	3420
q22	447	451	370	370
Total cold run time: 48489 ms
Total hot run time: 46149 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 183261 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 8419725b9ea47556bae814100cf8e3a5e11ae9e3, data reload: false

query5	4549	648	519	519
query6	331	226	209	209
query7	4223	468	268	268
query8	331	240	241	240
query9	8740	2694	2743	2694
query10	527	391	337	337
query11	16964	17647	17143	17143
query12	212	129	128	128
query13	1750	498	398	398
query14	6923	3324	3095	3095
query14_1	3020	2957	2870	2870
query15	208	202	198	198
query16	1042	518	449	449
query17	1341	762	639	639
query18	2950	472	373	373
query19	237	224	190	190
query20	145	151	134	134
query21	223	146	120	120
query22	5421	5000	4829	4829
query23	17225	16780	16635	16635
query23_1	16693	16665	16626	16626
query24	7147	1612	1241	1241
query24_1	1223	1262	1196	1196
query25	576	485	438	438
query26	1234	268	161	161
query27	2749	476	284	284
query28	4449	1833	1853	1833
query29	771	561	466	466
query30	306	244	208	208
query31	862	736	647	647
query32	80	72	70	70
query33	501	355	281	281
query34	908	905	566	566
query35	630	668	590	590
query36	1080	1141	970	970
query37	131	91	81	81
query38	2982	2919	2840	2840
query39	898	874	840	840
query39_1	841	818	838	818
query40	237	148	134	134
query41	63	72	65	65
query42	104	104	100	100
query43	369	386	357	357
query44	
query45	200	193	182	182
query46	878	979	602	602
query47	2129	2157	2044	2044
query48	309	321	238	238
query49	633	467	376	376
query50	663	271	213	213
query51	4051	4092	4155	4092
query52	109	111	96	96
query53	288	335	285	285
query54	310	267	253	253
query55	89	83	80	80
query56	308	312	338	312
query57	1343	1309	1282	1282
query58	284	281	278	278
query59	2624	2679	2529	2529
query60	338	336	308	308
query61	149	150	156	150
query62	644	599	532	532
query63	321	273	275	273
query64	4874	1274	973	973
query65	
query66	1379	452	379	379
query67	16346	16359	16222	16222
query68	
query69	398	295	273	273
query70	998	971	955	955
query71	334	312	296	296
query72	2777	2640	2405	2405
query73	531	546	325	325
query74	9956	9907	9758	9758
query75	2833	2741	2446	2446
query76	2291	1054	672	672
query77	356	377	307	307
query78	11211	11652	10717	10717
query79	2661	821	610	610
query80	1854	622	523	523
query81	570	281	247	247
query82	1011	146	118	118
query83	357	258	249	249
query84	252	119	100	100
query85	886	461	433	433
query86	411	300	291	291
query87	3112	3085	2992	2992
query88	3533	2665	2655	2655
query89	429	359	337	337
query90	2028	176	169	169
query91	163	158	127	127
query92	81	76	71	71
query93	1433	806	497	497
query94	647	322	295	295
query95	586	388	319	319
query96	638	506	225	225
query97	2447	2499	2395	2395
query98	229	218	219	218
query99	1011	986	908	908
Total cold run time: 258350 ms
Total hot run time: 183261 ms

dataroaring
dataroaring previously approved these changes Feb 28, 2026
Copy link
Contributor

@dataroaring dataroaring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Feb 28, 2026
@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@sollhui
Copy link
Contributor Author

sollhui commented Feb 28, 2026

run buildall

@github-actions github-actions bot removed the approved Indicates a PR has been approved by one committer. label Feb 28, 2026
@doris-robot
Copy link

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

------ Round 1 ----------------------------------
============================================
q1	17706	4542	4260	4260
q2	q3	10653	777	544	544
q4	4674	355	254	254
q5	7553	1196	1017	1017
q6	173	177	146	146
q7	764	843	688	688
q8	9525	1478	1288	1288
q9	4875	4764	4694	4694
q10	6834	1860	1641	1641
q11	461	262	223	223
q12	745	565	465	465
q13	17787	4202	3382	3382
q14	234	228	217	217
q15	944	788	791	788
q16	750	707	686	686
q17	737	879	415	415
q18	6059	5415	5321	5321
q19	1273	968	610	610
q20	512	489	385	385
q21	4937	1912	1471	1471
q22	360	344	270	270
Total cold run time: 97556 ms
Total hot run time: 28765 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4611	4527	4592	4527
q2	q3	1826	2235	1725	1725
q4	872	1204	779	779
q5	4089	4453	4432	4432
q6	182	187	145	145
q7	1761	1669	1542	1542
q8	2507	2706	2535	2535
q9	7413	7537	7316	7316
q10	2610	2842	2422	2422
q11	518	431	435	431
q12	521	606	516	516
q13	4279	4386	3578	3578
q14	288	297	291	291
q15	888	828	809	809
q16	725	763	726	726
q17	1154	1556	1320	1320
q18	7248	6837	6669	6669
q19	857	812	871	812
q20	2078	2169	1993	1993
q21	3956	3496	3340	3340
q22	473	463	392	392
Total cold run time: 48856 ms
Total hot run time: 46300 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 183639 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 d852eb0dfe6eb7aae8e99c977751963d2439f124, data reload: false

query5	4528	634	511	511
query6	322	221	219	219
query7	4229	460	272	272
query8	348	246	241	241
query9	8761	2750	2737	2737
query10	515	404	347	347
query11	16913	17269	17115	17115
query12	208	127	126	126
query13	1325	452	358	358
query14	6579	3268	3049	3049
query14_1	2955	3050	2986	2986
query15	224	208	181	181
query16	991	480	456	456
query17	1228	768	647	647
query18	3374	454	370	370
query19	226	218	198	198
query20	147	143	131	131
query21	233	144	119	119
query22	5450	4835	4927	4835
query23	17179	16659	16619	16619
query23_1	16631	16749	16819	16749
query24	7280	1612	1227	1227
query24_1	1226	1233	1236	1233
query25	564	477	420	420
query26	1237	263	151	151
query27	2753	514	277	277
query28	4429	1850	1875	1850
query29	775	545	463	463
query30	312	243	210	210
query31	866	737	663	663
query32	82	74	71	71
query33	533	339	278	278
query34	913	908	565	565
query35	620	673	588	588
query36	1075	1167	941	941
query37	130	92	77	77
query38	2924	2876	2859	2859
query39	1003	866	847	847
query39_1	822	817	823	817
query40	226	151	131	131
query41	64	61	58	58
query42	104	102	100	100
query43	374	376	351	351
query44	
query45	200	194	185	185
query46	879	973	596	596
query47	2118	2132	2032	2032
query48	302	306	227	227
query49	625	460	385	385
query50	669	271	218	218
query51	4116	4099	4132	4099
query52	106	109	94	94
query53	284	336	280	280
query54	294	266	259	259
query55	88	83	78	78
query56	306	308	334	308
query57	1358	1343	1276	1276
query58	287	278	277	277
query59	2536	2687	2559	2559
query60	323	321	321	321
query61	146	143	147	143
query62	619	585	533	533
query63	306	279	285	279
query64	4818	1274	985	985
query65	
query66	1419	447	351	351
query67	16407	16449	16241	16241
query68	
query69	400	309	272	272
query70	990	975	950	950
query71	332	293	286	286
query72	2693	2706	2402	2402
query73	533	536	314	314
query74	10000	9930	9779	9779
query75	2825	2728	2438	2438
query76	2311	1028	673	673
query77	351	388	331	331
query78	11217	11361	10747	10747
query79	2479	800	606	606
query80	1811	595	546	546
query81	559	284	246	246
query82	1013	149	111	111
query83	330	256	247	247
query84	251	113	99	99
query85	915	468	421	421
query86	406	305	310	305
query87	3104	3112	3068	3068
query88	3519	2679	2644	2644
query89	429	363	368	363
query90	2022	180	171	171
query91	165	151	133	133
query92	79	74	69	69
query93	991	824	497	497
query94	626	320	285	285
query95	588	397	307	307
query96	637	508	229	229
query97	2487	2485	2416	2416
query98	220	217	213	213
query99	994	1009	911	911
Total cold run time: 255355 ms
Total hot run time: 183639 ms

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.

4 participants