You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "Yukang-Lian (via GitHub)" <gi...@apache.org> on 2026/10/15 11:30:31 UTC

[PR] [fix](cloud) Remove intermediate rowsets of sorting schema change from file cache path [doris]

Yukang-Lian opened a new pull request, #69134:
URL: https://github.com/apache/doris/pull/69134

   ### What problem does this PR solve?
   
   Issue Number: None
   
   Related PR: None
   
   Problem Summary:
   
   In cloud mode, a schema change that has to sort data (e.g. adding a rollup or a sync materialized view whose key columns are in a different order) writes the intermediate rowsets of internal sorting to a local path. These rowsets have no storage resource, so `CloudRowsetWriter::init` puts them in the root of a file cache path as `<rowset_id>_<segment_id>.dat`. Every input rowset with data produces at least one intermediate rowset, so each such schema change writes a full copy of the converted data there.
   
   Only the local mode subclass `VLocalSchemaChangeWithSorting` removes the intermediate rowsets. Cloud mode uses `VBaseSchemaChangeWithSorting` directly, which never removes them, whether the schema change succeeds or fails. These files are not part of the file cache: cache eviction and `clear_file_cache` API do not see them, and the cache loader skips regular files in the cache root on restart. They pile up on the cache disk until it is full, the file cache then evicts its own data and cannot admit new blocks, and reads fall back to remote storage. We observed hundreds of GB of such files on a cluster which created sync materialized views repeatedly.
   
   This PR:
   
   - Adds `VCloudSchemaChangeWithSorting`, used by cloud schema change, which removes the intermediate rowsets after each input rowset is processed, whether it succeeds or fails (like `VLocalSchemaChangeWithSorting` does in local mode).
   - Removes the local rowset files left in file cache paths by previous BE processes (e.g. BE crashed during schema change) when `CloudStorageEngine` opens. A rowset id embeds the backend uid of the process that generated it, which is regenerated on every start, so only files from previous processes are removed and files written by the current process are never touched. Only regular files whose names match the local rowset file format are considered.
   - Adds a debug point `VBaseSchemaChangeWithSorting._inner_process.before_external_sorting` to inject a failure in tests.
   
   ### Release note
   
   Fix the intermediate rowsets of schema change with sorting being left in the file cache path in cloud mode, which could fill up the cache disk.
   
   ### Check List (For Author)
   
   - Test <!-- At least one of them must be included. -->
       - [x] Regression test
       - [x] 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 <!-- Add your reason?  -->
   
       Unit tests (`CloudSchemaChangeSortingTest`) run a real sorting schema change in cloud mode and check the file cache root after success and after an injected failure, and cover the startup cleanup of stale rowset files. Without the cleanup, the success and failure cases fail with the intermediate rowsets left in the cache root.
   
       The docker regression test `test_cloud_sc_sorting_tmp_rowset_cleanup` covers a rollup that reorders keys, a failed rollup, and BE restart with stale rowset files in the cache root. On the code before this PR it fails at the first step (`expected: <0> but was: <5>`, one leftover intermediate rowset per loaded rowset).
   
   - Behavior changed:
       - [ ] No.
       - [x] Yes. <!-- Explain the behavior change -->
         In cloud mode, intermediate rowsets of schema change with sorting are removed after use, and stale ones in file cache paths are removed when BE starts.
   
   - Does this need documentation?
       - [x] No.
       - [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 -->
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](cloud) Remove intermediate rowsets of sorting schema change from file cache path [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69134:
URL: https://github.com/apache/doris/pull/69134#issuecomment-6191965188

   
   <details>
   <summary>TPC-H: <b>Total hot run time: 29768 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
   Tpch sf100 test result on commit dbb037488e64e0604fc459a56db836568443fe0c, data reload: false
   
   ------ Round 1 ----------------------------------
   ============================================
   q1	17619	5695	5571	5571
   q2	2135	348	260	260
   q3	10185	1425	852	852
   q4	4669	477	340	340
   q5	7428	796	531	531
   q6	195	189	158	158
   q7	758	797	611	611
   q8	9246	1331	1130	1130
   q9	5612	4295	4288	4288
   q10	6815	1296	1028	1028
   q11	424	256	241	241
   q12	630	398	286	286
   q13	18088	3607	3021	3021
   q14	280	283	250	250
   q15	q16	741	729	677	677
   q17	1213	744	563	563
   q18	7093	6230	6194	6194
   q19	1107	972	599	599
   q20	407	342	233	233
   q21	5905	2639	2636	2636
   q22	398	348	299	299
   Total cold run time: 100948 ms
   Total hot run time: 29768 ms
   
   ----- Round 2, with runtime_filter_mode=off -----
   ============================================
   q1	6652	6680	6720	6680
   q2	760	616	570	570
   q3	5541	5773	5277	5277
   q4	2090	2200	1569	1569
   q5	5854	5622	5896	5622
   q6	246	202	149	149
   q7	2245	1994	1834	1834
   q8	3142	2768	2707	2707
   q9	8023	8019	7649	7649
   q10	3657	3595	3251	3251
   q11	591	396	373	373
   q12	666	699	505	505
   q13	3353	3577	3011	3011
   q14	285	285	262	262
   q15	q16	671	673	604	604
   q17	7837	7083	6888	6888
   q18	13071	12214	12972	12214
   q19	909	824	790	790
   q20	2174	2159	1931	1931
   q21	5795	4690	4803	4690
   q22	510	459	399	399
   Total cold run time: 74072 ms
   Total hot run time: 66975 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](cloud) Remove intermediate rowsets of sorting schema change from file cache path [doris]

Posted by "Yukang-Lian (via GitHub)" <gi...@apache.org>.
Yukang-Lian commented on PR #69134:
URL: https://github.com/apache/doris/pull/69134#issuecomment-6191057696

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](cloud) Remove intermediate rowsets of sorting schema change from file cache path [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69134:
URL: https://github.com/apache/doris/pull/69134#issuecomment-6192145318

   
   <details>
   <summary>TPC-DS: <b>Total hot run time: 152056 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
   TPC-DS sf100 test result on commit dbb037488e64e0604fc459a56db836568443fe0c, data reload: false
   
   query5	4310	593	473	473
   query6	430	200	194	194
   query7	4808	436	228	228
   query8	317	165	155	155
   query9	8771	3957	3953	3953
   query10	467	317	268	268
   query11	6045	3828	3553	3553
   query12	151	96	89	89
   query13	1265	447	347	347
   query14	6058	4057	3701	3701
   query14_1	3520	3491	3541	3491
   query15	207	201	182	182
   query16	950	446	419	419
   query17	859	669	538	538
   query18	2418	430	310	310
   query19	199	169	140	140
   query20	87	86	82	82
   query21	206	132	112	112
   query22	12846	12955	12863	12863
   query23	13547	12779	12399	12399
   query23_1	12528	12634	12562	12562
   query24	7119	837	472	472
   query24_1	479	497	476	476
   query25	541	418	364	364
   query26	1308	263	146	146
   query27	2747	438	279	279
   query28	4610	1961	1963	1961
   query29	1590	610	457	457
   query30	302	231	188	188
   query31	1009	928	806	806
   query32	147	90	96	90
   query33	527	319	250	250
   query34	922	856	495	495
   query35	752	761	642	642
   query36	808	801	727	727
   query37	133	104	86	86
   query38	1807	1781	1686	1686
   query39	808	821	746	746
   query39_1	735	729	744	729
   query40	219	114	98	98
   query41	73	69	70	69
   query42	88	85	82	82
   query43	372	390	331	331
   query44	1329	708	718	708
   query45	216	181	163	163
   query46	846	966	576	576
   query47	2928	3006	2763	2763
   query48	294	316	219	219
   query49	576	393	292	292
   query50	696	274	220	220
   query51	10833	10688	10436	10436
   query52	79	83	69	69
   query53	184	219	160	160
   query54	264	192	181	181
   query55	74	71	65	65
   query56	229	206	213	206
   query57	1640	1565	1532	1532
   query58	291	278	257	257
   query59	2142	2127	1981	1981
   query60	302	236	225	225
   query61	143	135	137	135
   query62	389	335	303	303
   query63	196	163	163	163
   query64	2735	919	762	762
   query65	3331	3282	3238	3238
   query66	1784	459	306	306
   query67	20093	19994	20246	19994
   query68	2891	1001	627	627
   query69	406	282	240	240
   query70	868	786	794	786
   query71	286	230	190	190
   query72	2659	2544	2257	2257
   query73	507	529	295	295
   query74	4580	4458	4289	4289
   query75	2336	2284	1925	1925
   query76	2297	1020	615	615
   query77	337	357	278	278
   query78	9889	9713	9138	9138
   query79	993	845	522	522
   query80	832	416	357	357
   query81	591	318	269	269
   query82	751	135	112	112
   query83	306	189	182	182
   query84	316	127	96	96
   query85	921	428	367	367
   query86	363	238	231	231
   query87	1998	1954	1836	1836
   query88	3599	2700	2654	2654
   query89	340	294	255	255
   query90	1766	185	183	183
   query91	167	156	134	134
   query92	102	92	89	89
   query93	997	1005	581	581
   query94	562	311	294	294
   query95	576	357	381	357
   query96	680	517	234	234
   query97	2453	2423	2325	2325
   query98	164	150	149	149
   query99	781	766	657	657
   Total cold run time: 234675 ms
   Total hot run time: 152056 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](cloud) Remove intermediate rowsets of sorting schema change from file cache path [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69134:
URL: https://github.com/apache/doris/pull/69134#issuecomment-6192235637

   
   <details>
   <summary>ClickBench: <b>Total hot run time: 24.48 s</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
   ClickBench test result on commit dbb037488e64e0604fc459a56db836568443fe0c, data reload: false
   
   query1	0.01	0.00	0.01
   query2	0.09	0.05	0.05
   query3	0.26	0.12	0.11
   query4	1.60	0.12	0.12
   query5	0.27	0.22	0.22
   query6	1.17	0.68	0.68
   query7	0.04	0.01	0.00
   query8	0.05	0.04	0.04
   query9	0.40	0.34	0.35
   query10	0.61	0.57	0.54
   query11	0.20	0.14	0.14
   query12	0.19	0.15	0.14
   query13	0.51	0.51	0.50
   query14	1.01	1.01	1.01
   query15	0.62	0.60	0.61
   query16	0.35	0.36	0.31
   query17	1.16	1.15	1.15
   query18	0.22	0.22	0.20
   query19	2.11	2.00	1.98
   query20	0.02	0.01	0.01
   query21	15.50	0.25	0.14
   query22	4.48	0.06	0.05
   query23	16.25	0.31	0.12
   query24	3.22	0.59	0.40
   query25	0.10	0.06	0.05
   query26	1.05	0.24	0.14
   query27	0.05	0.03	0.04
   query28	1.95	0.62	0.40
   query29	12.48	4.14	3.32
   query30	0.29	0.14	0.13
   query31	2.77	0.57	0.33
   query32	3.23	0.62	0.52
   query33	3.22	3.26	3.19
   query34	15.52	3.98	3.40
   query35	3.34	3.34	3.34
   query36	0.54	0.46	0.42
   query37	0.09	0.06	0.06
   query38	0.05	0.04	0.04
   query39	0.03	0.03	0.03
   query40	0.17	0.16	0.15
   query41	0.08	0.04	0.02
   query42	0.04	0.03	0.03
   query43	0.04	0.04	0.03
   Total cold run time: 95.38 s
   Total hot run time: 24.48 s
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](cloud) Remove intermediate rowsets of sorting schema change from file cache path [doris]

Posted by "Yukang-Lian (via GitHub)" <gi...@apache.org>.
Yukang-Lian commented on PR #69134:
URL: https://github.com/apache/doris/pull/69134#issuecomment-6210814206

   /review


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](cloud) Remove intermediate rowsets of sorting schema change from file cache path [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69134:
URL: https://github.com/apache/doris/pull/69134#issuecomment-6191018855

   
   Thank you for your contribution to Apache Doris.
   Don't know what should be done next? See [How to process your PR](https://doris.apache.org/community/how-to-contribute/review-and-ci).
   
   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?
       


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](cloud) Remove intermediate rowsets of sorting schema change from file cache path [doris]

Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #69134:
URL: https://github.com/apache/doris/pull/69134#issuecomment-6195290723

   # BE Regression && UT Coverage Report
   Increment line coverage `100% (0/0)` :tada:
   
   [Increment coverage report](http://coverage.selectdb-in.cc/coverage/69134_dbb037488e64e0604fc459a56db836568443fe0c_merge/increment_report/index.html)
   [Complete coverage report](http://coverage.selectdb-in.cc/coverage/69134_dbb037488e64e0604fc459a56db836568443fe0c_merge/report/index.html)
   | Category          | Coverage           |
   |-------------------|--------------------|
   | Function Coverage | 77.08% (35717/46337) |
   | Line Coverage     | 62.39% (405047/649221) |
   | Region Coverage   | 58.82% (342233/581867) |
   | Branch Coverage   | 59.69% (157814/264385) |


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](cloud) Remove intermediate rowsets of sorting schema change from file cache path [doris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #69134:
URL: https://github.com/apache/doris/pull/69134#discussion_r4292420693


##########
be/src/cloud/cloud_schema_change_job.cpp:
##########
@@ -54,12 +54,30 @@ static constexpr int SCHEMA_CHANGE_DELETE_BITMAP_LOCK_ID = -2;
 std::unique_ptr<SchemaChange> get_sc_procedure(const BlockChanger& changer, bool sc_sorting,
                                                int64_t mem_limit) {
     if (sc_sorting) {
-        return std::make_unique<VBaseSchemaChangeWithSorting>(changer, mem_limit);
+        return std::make_unique<VCloudSchemaChangeWithSorting>(changer, mem_limit);
     }
     // else sc_directly
     return std::make_unique<VSchemaChangeDirectly>(changer);
 }
 
+Status VCloudSchemaChangeWithSorting::_inner_process(RowsetReaderSharedPtr rowset_reader,
+                                                     RowsetWriter* rowset_writer,
+                                                     BaseTabletSPtr new_tablet,
+                                                     TabletSchemaSPtr base_tablet_schema,
+                                                     TabletSchemaSPtr new_tablet_schema) {
+    Defer defer {[&]() {
+        // remove the intermediate rowsets generated by internal sorting
+        for (auto& rowset : _src_rowsets) {

Review Comment:
   [P2] Include failed spill index files in cleanup
   
   When internal sorting finishes an indexed segment and then fails while opening/writing the next one (for example, ENOSPC during a cloud base-table key reorder with a retained inverted index), `_internal_sorting()` returns before that spill is pushed into `_src_rowsets`. The failed writer's existing destructor removes only `.dat` files; completed `.idx` outputs are not unlinked by their writers. This cleanup therefore still leaves those index files occupying the cache disk until BE restart. Please cover index outputs from failed spill writers too and add an indexed failure before `build()`; the new failure point only runs after all spills have built.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org