Skip to content

[fix](cloud) Set file cache TTL on cloud schema change output - #67454

Open
liaoxin01 wants to merge 1 commit into
apache:masterfrom
liaoxin01:fix-sc-output-file-cache-ttl-master
Open

[fix](cloud) Set file cache TTL on cloud schema change output#67454
liaoxin01 wants to merge 1 commit into
apache:masterfrom
liaoxin01:fix-sc-output-file-cache-ttl-master

Conversation

@liaoxin01

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

CloudSchemaChangeJob::_convert_historical_rowsets() builds its RowsetWriterContext with write_file_cache but never sets file_cache_ttl_sec. For a table with file_cache_ttl_seconds, the schema change output is therefore written into the NORMAL/INDEX file cache queues instead of the TTL queue. The other two cloud write paths both set it:

  • load: CloudRowsetBuilder::init()context.file_cache_ttl_sec = _tablet->ttl_seconds();
  • compaction: CloudCompactionMixin::construct_output_rowset_writer()ctx.file_cache_ttl_sec = _tablet->ttl_seconds();

Two consequences:

  1. The schema change output cannot be retained by the table TTL on the cluster that runs the job, and can be evicted early by the NORMAL/INDEX LRU.
  2. Every warm-up path on the destination cluster derives the expiration from tablet_meta->ttl_seconds() unconditionally — event driven (CloudInternalService::warm_up_rowset), sync rowset (CloudTablet::add_rowsets) and warm-up job (CloudWarmUpManager) — so the very same rowsets land in the TTL queue there. Source and destination end up with the same total cached bytes but different queue attribution.

This is what test_warm_up_cluster_event_schema_change catches. After the schema change, checkTTLCacheSizeSumEqual() fails because the destination ttl_cache_size exceeds the source by exactly the size of the schema change output:

test_warm_up_cluster_event_schema_change.groovy:132
assertEquals(srcSum, tgtSum)
expected: 229588
but was:  489694

489694 - 229588 = 260106 = 148362 (data) + 111744 (index), which is exactly what the schema change job wrote (its log shows input_hit_rate=1, should_cache=1, so the output was cached — just in the wrong queue).

The fix takes the TTL from the new tablet, which is the same tablet the warm-up paths read it from.

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

Covered by the existing test_warm_up_cluster_event_schema_change, which fails before this change and passes after it.

  • Behavior changed:

    • No.
    • Yes. For a table with file_cache_ttl_seconds, the cloud schema change output is now cached in the TTL queue instead of the NORMAL/INDEX queues, matching the load and compaction paths.
  • 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

`CloudSchemaChangeJob::_convert_historical_rowsets()` builds its
`RowsetWriterContext` with `write_file_cache` but never sets
`file_cache_ttl_sec`, so for a table with `file_cache_ttl_seconds` the
schema change output is written into the NORMAL/INDEX cache queues
instead of the TTL queue. The load path (`CloudRowsetBuilder::init()`)
and the compaction path (`CloudCompactionMixin::construct_output_rowset_writer()`)
both set it.

Two consequences:

- The schema change output cannot be retained by the table TTL on the
  cluster that runs the job, and can be evicted early by NORMAL/INDEX LRU.
- Every warm-up path on the destination cluster (event driven, sync
  rowset and warm-up job) derives the expiration from
  `tablet_meta->ttl_seconds()` unconditionally, so the same rowsets land
  in the TTL queue there. Source and destination end up with the same
  cached bytes but different queues.

This is what `test_warm_up_cluster_event_schema_change` catches: after a
schema change the `ttl_cache_size` of the destination cluster exceeds the
source by exactly the size of the schema change output.

Take the TTL from the new tablet, which is also the tablet the warm-up
paths read it from.
@liaoxin01
liaoxin01 requested a review from gavinchou as a code owner September 2, 2026 15:37
@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?

@liaoxin01

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17558	3043	3024	3024
q2	2088	261	224	224
q3	10236	855	514	514
q4	4664	248	199	199
q5	7685	575	388	388
q6	136	115	93	93
q7	517	489	375	375
q8	9237	910	904	904
q9	3422	2432	2422	2422
q10	6506	867	706	706
q11	395	196	181	181
q12	627	269	203	203
q13	18102	1502	1158	1158
q14	161	150	144	144
q15	q16	434	398	365	365
q17	1402	923	804	804
q18	3157	2253	2209	2209
q19	1258	929	758	758
q20	371	275	203	203
q21	5564	1853	1836	1836
q22	341	267	234	234
Total cold run time: 93861 ms
Total hot run time: 16944 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3385	3336	3311	3311
q2	521	393	363	363
q3	2198	2309	2156	2156
q4	1200	1197	891	891
q5	2165	2101	2095	2095
q6	173	122	87	87
q7	999	963	869	869
q8	1593	1412	1409	1409
q9	3113	3095	3069	3069
q10	1897	1802	1633	1633
q11	355	271	247	247
q12	455	425	338	338
q13	1484	1507	1185	1185
q14	162	171	157	157
q15	q16	395	396	353	353
q17	3606	3289	3194	3194
q18	4802	4425	4687	4425
q19	843	796	914	796
q20	1007	989	815	815
q21	3888	3106	3214	3106
q22	397	345	319	319
Total cold run time: 34638 ms
Total hot run time: 30818 ms

@hello-stephen

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

query5	4250	412	336	336
query6	388	130	120	120
query7	4948	425	220	220
query8	285	125	114	114
query9	8716	2876	2890	2876
query10	405	223	186	186
query11	5355	1032	910	910
query12	117	73	73	73
query13	1208	471	334	334
query14	6149	2189	2062	2062
query14_1	1969	1954	1941	1941
query15	177	122	113	113
query16	916	344	340	340
query17	812	458	371	371
query18	2348	327	235	235
query19	165	142	109	109
query20	74	71	70	70
query21	203	99	85	85
query22	5352	5331	5227	5227
query23	6765	6209	6044	6044
query23_1	6074	5951	5917	5917
query24	7240	1083	778	778
query24_1	784	797	775	775
query25	413	279	231	231
query26	1214	231	124	124
query27	2789	416	250	250
query28	4693	1496	1505	1496
query29	917	406	337	337
query30	252	151	130	130
query31	816	395	328	328
query32	124	73	70	70
query33	434	194	177	177
query34	1009	821	485	485
query35	391	390	335	335
query36	581	564	524	524
query37	116	82	79	79
query38	999	845	810	810
query39	503	471	473	471
query39_1	463	443	457	443
query40	208	89	79	79
query41	54	52	51	51
query42	73	70	75	70
query43	237	248	210	210
query44	1019	548	550	548
query45	105	106	99	99
query46	826	806	522	522
query47	742	772	711	711
query48	315	306	222	222
query49	525	232	185	185
query50	744	266	192	192
query51	8108	8128	8172	8128
query52	69	71	65	65
query53	191	201	157	157
query54	249	189	175	175
query55	74	62	54	54
query56	198	176	175	175
query57	680	650	664	650
query58	309	163	167	163
query59	1223	1236	1091	1091
query60	259	191	203	191
query61	134	134	139	134
query62	382	211	183	183
query63	173	140	152	140
query64	2715	730	636	636
query65	1582	1604	1627	1604
query66	1864	264	231	231
query67	9522	9659	9741	9659
query68	2779	1220	727	727
query69	321	213	191	191
query70	666	637	594	594
query71	242	187	166	166
query72	2289	1753	1571	1571
query73	655	579	359	359
query74	1569	1216	1119	1119
query75	1163	1099	960	960
query76	2283	726	543	543
query77	238	247	213	213
query78	3791	3657	3242	3242
query79	2516	845	617	617
query80	1616	327	268	268
query81	491	161	131	131
query82	618	124	96	96
query83	289	220	201	201
query84	303	114	91	91
query85	795	364	339	339
query86	408	180	171	171
query87	1023	958	900	900
query88	2792	2100	2114	2100
query89	265	195	169	169
query90	1980	137	130	130
query91	132	125	100	100
query92	79	71	61	61
query93	1666	1067	729	729
query94	652	263	215	215
query95	523	264	219	219
query96	832	614	291	291
query97	1044	1029	1007	1007
query98	162	140	133	133
query99	423	348	308	308
Total cold run time: 177025 ms
Total hot run time: 81971 ms

@hello-stephen

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

query1	0.01	0.00	0.00
query2	0.07	0.04	0.03
query3	0.25	0.11	0.10
query4	1.60	0.10	0.09
query5	0.18	0.17	0.17
query6	1.24	0.70	0.69
query7	0.03	0.01	0.00
query8	0.04	0.02	0.03
query9	0.29	0.21	0.22
query10	0.36	0.35	0.34
query11	0.16	0.11	0.12
query12	0.15	0.12	0.12
query13	0.30	0.30	0.30
query14	0.46	0.44	0.44
query15	0.36	0.35	0.34
query16	0.23	0.23	0.24
query17	0.68	0.71	0.68
query18	0.17	0.15	0.16
query19	1.18	1.18	1.09
query20	0.02	0.01	0.01
query21	15.44	0.16	0.11
query22	5.09	0.05	0.04
query23	16.16	0.24	0.10
query24	3.14	0.31	0.25
query25	0.11	0.03	0.04
query26	0.72	0.17	0.14
query27	0.03	0.04	0.02
query28	3.63	0.55	0.27
query29	12.43	3.14	2.56
query30	0.25	0.12	0.13
query31	2.76	0.36	0.16
query32	3.53	0.33	0.22
query33	1.34	1.43	1.45
query34	15.38	2.22	1.76
query35	1.74	1.72	1.68
query36	0.46	0.29	0.28
query37	0.05	0.04	0.04
query38	0.04	0.03	0.03
query39	0.03	0.02	0.02
query40	0.11	0.08	0.07
query41	0.08	0.02	0.03
query42	0.03	0.03	0.03
query43	0.03	0.03	0.03
Total cold run time: 90.36 s
Total hot run time: 14.53 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.17% (34658/45503)
Line Coverage 61.23% (391171/638810)
Region Coverage 57.44% (328826/572516)
Branch Coverage 58.17% (149861/257639)

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.

3 participants