Skip to content

Conversation

@suxiaogang223
Copy link
Contributor

@suxiaogang223 suxiaogang223 commented Jan 23, 2026

What problem does this PR solve?

Problem

Queries like FOR VERSION AS OF '<tag>' fail when the tag points to a snapshot whose snapshot file has expired, even though the tag is still valid and data should be retained by tag.

Root Cause

Doris always translated time-travel requests into scan.snapshot-id. Paimon validates snapshot-id against the current snapshot range; once a snapshot file is expired, it is out of range and the query fails. Tag-based reads should use scan.tag-name instead, which bypasses that snapshot range validation.

Fix

Use scan.tag-name for tag-based time travel (@tag and FOR VERSION AS OF '<tag>'), and keep scan.snapshot-id only for numeric snapshot-id queries. Add regression coverage that:

  • validates tag reads succeed after snapshot expiration
  • validates direct snapshot-id reads against expired snapshots still fail

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

@Thearas
Copy link
Contributor

Thearas commented Jan 23, 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?

@suxiaogang223
Copy link
Contributor Author

run external

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 95.24% (20/21) 🎉
Increment coverage report
Complete coverage report

@suxiaogang223
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17637	4757	4559	4559
q2	2039	320	231	231
q3	10190	1284	743	743
q4	10213	851	314	314
q5	7543	2080	1828	1828
q6	190	173	146	146
q7	874	706	607	607
q8	9276	1360	1129	1129
q9	4878	4587	4582	4582
q10	6798	1651	1246	1246
q11	548	304	286	286
q12	339	374	230	230
q13	17788	3804	3078	3078
q14	227	232	222	222
q15	607	529	528	528
q16	648	636	611	611
q17	642	738	570	570
q18	6558	6367	6439	6367
q19	1280	969	636	636
q20	405	340	231	231
q21	2609	1984	1958	1958
q22	1024	991	968	968
Total cold run time: 102313 ms
Total hot run time: 31070 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4761	4656	4673	4656
q2	326	405	325	325
q3	2207	2701	2308	2308
q4	1363	1801	1355	1355
q5	4237	4015	4111	4015
q6	218	172	135	135
q7	1860	1828	1658	1658
q8	2862	2500	2468	2468
q9	7302	7142	7321	7142
q10	2487	2698	2415	2415
q11	563	481	460	460
q12	756	771	644	644
q13	3663	4043	3496	3496
q14	283	318	272	272
q15	570	512	529	512
q16	637	705	686	686
q17	1131	1451	1386	1386
q18	8119	8049	7966	7966
q19	881	927	978	927
q20	2030	2066	1903	1903
q21	4845	4501	4128	4128
q22	1090	1047	983	983
Total cold run time: 52191 ms
Total hot run time: 49840 ms

@doris-robot
Copy link

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

query5	4356	641	495	495
query6	322	214	194	194
query7	4210	484	249	249
query8	331	258	258	258
query9	8677	2816	2845	2816
query10	451	314	270	270
query11	15289	15106	14746	14746
query12	182	119	140	119
query13	1235	456	366	366
query14	5545	2996	2913	2913
query14_1	2642	2651	2616	2616
query15	204	189	167	167
query16	949	467	453	453
query17	870	662	549	549
query18	2425	419	325	325
query19	191	176	145	145
query20	121	114	116	114
query21	211	144	123	123
query22	3831	4056	4089	4056
query23	15961	15489	15308	15308
query23_1	15489	15508	15326	15326
query24	7173	1534	1186	1186
query24_1	1176	1192	1203	1192
query25	543	451	403	403
query26	1243	268	153	153
query27	2754	447	278	278
query28	4596	2149	2135	2135
query29	790	565	457	457
query30	306	241	209	209
query31	776	630	543	543
query32	85	75	73	73
query33	536	361	326	326
query34	912	889	540	540
query35	712	760	688	688
query36	881	916	800	800
query37	145	101	92	92
query38	2731	2672	2613	2613
query39	794	750	720	720
query39_1	701	732	709	709
query40	223	142	118	118
query41	74	69	68	68
query42	99	94	95	94
query43	445	456	431	431
query44	1363	761	744	744
query45	192	189	183	183
query46	849	958	604	604
query47	1439	1538	1386	1386
query48	313	332	244	244
query49	623	443	366	366
query50	703	271	213	213
query51	3760	3869	3767	3767
query52	92	93	82	82
query53	203	229	174	174
query54	299	272	265	265
query55	84	81	81	81
query56	321	321	306	306
query57	1031	1001	932	932
query58	276	264	267	264
query59	2160	2193	2003	2003
query60	340	332	321	321
query61	169	169	169	169
query62	384	371	315	315
query63	199	166	171	166
query64	4913	1136	839	839
query65	3777	3760	3802	3760
query66	1459	407	315	315
query67	15412	15601	15313	15313
query68	2403	1069	713	713
query69	405	311	277	277
query70	993	948	944	944
query71	305	290	269	269
query72	5292	2474	3264	2474
query73	600	746	317	317
query74	8766	8673	8564	8564
query75	2281	2324	1870	1870
query76	2277	1065	657	657
query77	351	397	310	310
query78	9712	9867	9143	9143
query79	1230	906	579	579
query80	1273	509	442	442
query81	530	259	230	230
query82	998	155	115	115
query83	331	261	244	244
query84	298	121	91	91
query85	869	463	402	402
query86	418	301	287	287
query87	2877	2827	2769	2769
query88	3569	2567	2539	2539
query89	309	268	235	235
query90	1998	178	169	169
query91	162	159	127	127
query92	75	73	69	69
query93	1187	1020	640	640
query94	641	317	286	286
query95	587	397	344	344
query96	633	512	233	233
query97	2358	2394	2333	2333
query98	203	197	201	197
query99	611	566	505	505
Total cold run time: 245312 ms
Total hot run time: 171826 ms

@doris-robot
Copy link

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

query1	0.06	0.05	0.04
query2	0.10	0.05	0.05
query3	0.26	0.08	0.09
query4	1.60	0.11	0.11
query5	0.27	0.26	0.25
query6	1.15	0.66	0.66
query7	0.04	0.02	0.03
query8	0.05	0.04	0.04
query9	0.58	0.49	0.49
query10	0.56	0.55	0.54
query11	0.14	0.10	0.10
query12	0.14	0.10	0.10
query13	0.60	0.57	0.58
query14	0.95	0.95	0.93
query15	0.79	0.77	0.79
query16	0.42	0.38	0.38
query17	0.98	1.07	1.03
query18	0.24	0.21	0.22
query19	2.00	1.90	1.87
query20	0.02	0.01	0.01
query21	15.42	0.24	0.14
query22	4.87	0.05	0.04
query23	15.81	0.29	0.10
query24	1.53	0.29	0.19
query25	0.12	0.08	0.07
query26	0.14	0.13	0.13
query27	0.06	0.06	0.05
query28	3.64	1.10	0.88
query29	12.58	3.89	3.11
query30	0.28	0.13	0.12
query31	2.83	0.64	0.40
query32	3.24	0.57	0.47
query33	2.94	2.96	3.04
query34	16.41	5.13	4.47
query35	4.49	4.46	4.48
query36	0.68	0.51	0.48
query37	0.10	0.07	0.06
query38	0.06	0.04	0.03
query39	0.04	0.03	0.03
query40	0.18	0.14	0.14
query41	0.09	0.04	0.03
query42	0.04	0.02	0.02
query43	0.05	0.04	0.03
Total cold run time: 96.55 s
Total hot run time: 26.66 s

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 0.00% (0/21) 🎉
Increment coverage report
Complete coverage report

@hello-stephen
Copy link
Contributor

FE Regression Coverage Report

Increment line coverage 0.00% (0/21) 🎉
Increment coverage report
Complete coverage report

@github-actions
Copy link
Contributor

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

@github-actions github-actions bot added approved Indicates a PR has been approved by one committer. reviewed labels Jan 24, 2026
@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@morningman morningman merged commit 8de085d into apache:master Jan 26, 2026
34 of 35 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 26, 2026
…60166)

### What problem does this PR solve?

- Related PR: #53327 

## Problem
Queries like `FOR VERSION AS OF '<tag>'` fail when the tag points to a
snapshot whose snapshot file has expired, even though the tag is still
valid and data should be retained by tag.

## Root Cause
Doris always translated time-travel requests into `scan.snapshot-id`.
Paimon validates snapshot-id against the current snapshot range; once a
snapshot file is expired, it is out of range and the query fails.
Tag-based reads should use `scan.tag-name` instead, which bypasses that
snapshot range validation.

## Fix
Use `scan.tag-name` for tag-based time travel (`@tag` and `FOR VERSION
AS OF '<tag>'`), and keep `scan.snapshot-id` only for numeric
snapshot-id queries. Add regression coverage that:
- validates tag reads succeed after snapshot expiration
- validates direct snapshot-id reads against expired snapshots still
fail
yiguolei pushed a commit that referenced this pull request Jan 26, 2026
…d snapshots #60166 (#60222)

Cherry-picked from #60166

Co-authored-by: Socrates <suyiteng@selectdb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/3.1.x dev/4.0.3-merged reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants