Skip to content

[fix](packed-file) Honor write_file_cache option for packed small files - #69693

Merged
liaoxin01 merged 1 commit into
apache:masterfrom
liaoxin01:fix-packed-file-cache-write-switch
Oct 28, 2026
Merged

liaoxin01 merged 1 commit into
apache:masterfrom
liaoxin01:fix-packed-file-cache-write-switch

Conversation

@liaoxin01

@liaoxin01 liaoxin01 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: #59892, #60411, #64995

Problem Summary:

When packed file is enabled, the first segment file (.dat) and the index file (.idx) of a rowset are written through PackedFileSystem. The packed path decides whether to cache each small file from PackedAppendContext::write_file_cache, which defaults to true. RowsetWriterContext never sets this field.

PackedFileSystem::create_file_impl only copied the caller's FileWriterOptions::write_file_cache into the append context when enable_file_cache_write_index_file_only was on. With the default config, the packed path ignored the caller's choice and always wrote the small files to the NORMAL file cache queue.

So a load with disable_file_cache=true still filled the NORMAL queue whenever packed file was enabled. Files written directly to S3 honor the same flag and skip the cache. test_load_cache turns enable_packed_file on or off at random, so it fails intermittently with:

Scenario 1: Normal queue should be 0 bytes, but got 237288 bytes

The 237288 bytes are exactly the total size of the three packed segment files written by the load.

This PR always copies opts->write_file_cache into the append context when the caller passes options. Packed and direct writes now make the same cache decision. When opts is null, the packed path keeps the write_file_cache value already in the append context.

Other callers are not affected:

  • Rowset files always get their options from RowsetWriterContext::get_file_writer_options, so with write-index-only enabled the result is the same as before.
  • Compaction and schema change set allow_packed_file=false, so adaptive file cache write is not affected.
  • DeleteBitmapFileWriter builds PackedFileWriter directly, so it is not affected.

This PR also removes the BE_TEST-only accessor PackedFileWriter::buffer_capacity_for_test(). BE unit tests are compiled with -fno-access-control, so tests read private members directly.

Release note

Fix loads with disable_file_cache=true still writing data to the file cache when packed file is enabled.

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. With packed file enabled, writes whose options set write_file_cache=false (for example a load with disable_file_cache=true) no longer populate the file cache.
  • 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

@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
liaoxin01 force-pushed the fix-packed-file-cache-write-switch branch from 6f8c77a to 96b3c41 Compare October 27, 2026 13:27
PackedFileSystem only copied FileWriterOptions::write_file_cache into
PackedAppendContext when enable_file_cache_write_index_file_only was on.
Otherwise the append context kept its default true, so packed small files
were always written to the NORMAL file cache queue, even for a load with
disable_file_cache=true. Always follow the caller's option when one is
given, so packed and direct writes make the same cache decision.
@liaoxin01
liaoxin01 force-pushed the fix-packed-file-cache-write-switch branch from 96b3c41 to 16669e7 Compare October 27, 2026 13:35
@liaoxin01

Copy link
Copy Markdown
Contributor Author

/review

@liaoxin01

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.

Static review of PR #69693 at 16669e74d12391f08b767b6e28fa8b2600237903: no new actionable findings. There are no existing inline findings to carry forward. All four changed files, the relevant producers/consumers, and the required review checkpoints were covered; the complete reviewer and separate risk reviewer both returned NO_NEW_VALUABLE_FINDINGS in round 1.

Checkpoint conclusions:

  • Goal and evidence: the caller's false/true cache preference now reaches PackedAppendContext outside index-only mode and controls PackedFileManager's per-slice cache gate. The new unit test directly checks false, true, and null-option propagation; it does not exercise physical cache writes.
  • Scope and reuse: the predicate simplification, unused include removal, and test-accessor cleanup are small and consistent with the existing interfaces.
  • Concurrency and locking: each created writer receives its own copied context; shared filesystem policy is not mutated. Existing manager locking, task submission, and lock order are unchanged, with no additional heavy work under locks.
  • Lifecycle and static initialization: options are consumed during creation; writer ownership, asynchronous data captures, buffer release, and upload completion remain unchanged. No new globals, cross-TU initialization dependency, or ownership cycle is introduced.
  • Configuration: no configuration is added. Index-only overrides remain in RowsetWriterContext::get_file_writer_options; null options preserve the append-context policy.
  • Compatibility: no production layout, virtual interface, stored format, or rolling-upgrade protocol changes. The removed accessor was BE_TEST-only; the affected test target enables -fno-access-control, and no accessor callers remain. No new libc API is introduced; no binary ABI validation was performed.
  • Thrift/protobuf: no definitions or field IDs change.
  • Parallel paths: later segments and threshold fallback retain the original inner-writer options; V1 index exclusion, direct delete-bitmap packing, and read-side wrapping remain consistent. The only nonzero rowset adaptive-size producer is compaction, which disables packing, so no reachable adaptive-cache regression was found. Cloud schema change can use packing and now honors output_to_file_cache; the PR description's broader claim that schema change disables packing does not match that path.
  • Conditional checks and comments: the remaining null-options check has a supported fallback, and the nearby comment describes the concrete disable_file_cache failure. No speculative error guard is added.
  • Test coverage: targeted propagation coverage complements existing load-cache and packed index-only regressions. Related segment-routing and buffer-release tests remain applicable. Discovered index-only test mutations restore their saved configuration. No deterministic new end-to-end cache test is added, and the existing load-cache regression randomly selects packing.
  • Test results: no golden/result files change; the capacity assertions retain the accessor's exact meaning. Test execution was not performed.
  • Observability: existing cache metrics, async task/byte counters, and failure logs cover this optional cache work; no additional instrumentation is required for this change.
  • Transactions and persistence: visibility versions, delete bitmaps, rowset metadata, prepare/commit, and failover behavior are unchanged; this flag controls optional cache population.
  • Writes, errors, and crash behavior: authoritative remote append/upload and checked Status propagation remain intact. Skipping the best-effort cache task introduces no new atomicity, deadlock, or crash-cleanup path.
  • FE-BE variables: no new variable or sending path is introduced; the existing caller preference is consumed by the packed path.
  • Performance and memory: the existing context copy gains one boolean assignment. Disabling caching avoids the optional data copy/task and cache allocation; no new significant allocation or tracking obligation is introduced.
  • Module and other checks: public filesystem dispatch still uses FILESYSTEM_M. No reader-cache redesign, hub include addition, PCH/gate-table/template change, or test inclusion of source .cpp files is introduced. No additional issue emerged from the final special-case sweep.

No additional user focus was supplied. R1 (cache policy/adaptive/special paths) and R2 (private test access/global configuration) were independently verified and dismissed with source evidence. The final sweep found no unresolved in-scope candidate or static coverage gap. The review converged after 1 round.

Validation limit: static inspection only. No builds, tests, benchmarks, runtime cache validation, or release-artifact checks were run; optional external TDE implementations are outside the available checkout.

Review converged after 1 round(s).

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17599	5196	5062	5062
q2	2203	317	262	262
q3	10225	1431	836	836
q4	4676	473	347	347
q5	7446	809	527	527
q6	185	188	154	154
q7	745	811	607	607
q8	9253	1350	1050	1050
q9	5533	4195	4166	4166
q10	6840	1302	1048	1048
q11	420	241	227	227
q12	643	398	280	280
q13	18115	3695	3059	3059
q14	280	284	240	240
q15	q16	723	717	688	688
q17	1195	750	566	566
q18	7022	6174	6156	6156
q19	1245	975	597	597
q20	390	335	223	223
q21	5590	2127	2275	2127
q22	350	295	257	257
Total cold run time: 100678 ms
Total hot run time: 28479 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5610	5645	5852	5645
q2	685	583	550	550
q3	5222	5400	4913	4913
q4	2007	2132	1549	1549
q5	5261	5180	5734	5180
q6	257	200	148	148
q7	2346	2067	1865	1865
q8	3087	2872	2743	2743
q9	8160	8156	8170	8156
q10	3737	3650	3247	3247
q11	606	439	414	414
q12	678	725	522	522
q13	3646	3973	3258	3258
q14	323	324	288	288
q15	q16	689	703	655	655
q17	8313	7544	6890	6890
q18	12915	12181	12859	12181
q19	887	850	778	778
q20	2136	2129	1933	1933
q21	5567	4602	4656	4602
q22	525	446	427	427
Total cold run time: 72657 ms
Total hot run time: 65944 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 151476 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 16669e74d12391f08b767b6e28fa8b2600237903, data reload: false

query5	4316	605	452	452
query6	432	233	197	197
query7	4811	457	229	229
query8	320	176	157	157
query9	8785	3197	3205	3197
query10	476	308	270	270
query11	5912	3846	3560	3560
query12	149	93	87	87
query13	1275	425	320	320
query14	6145	3934	3618	3618
query14_1	3408	3427	3408	3408
query15	212	199	185	185
query16	939	433	411	411
query17	885	669	555	555
query18	2423	424	319	319
query19	202	170	142	142
query20	88	86	85	85
query21	212	127	105	105
query22	12985	12997	12971	12971
query23	13459	12872	12439	12439
query23_1	12434	12558	12604	12558
query24	7367	828	480	480
query24_1	488	502	500	500
query25	544	436	390	390
query26	1297	258	140	140
query27	2782	449	276	276
query28	4644	2048	2020	2020
query29	1593	608	462	462
query30	304	219	191	191
query31	1016	941	844	844
query32	154	95	98	95
query33	542	312	242	242
query34	985	853	506	506
query35	739	759	656	656
query36	859	861	731	731
query37	131	101	89	89
query38	1779	1752	1676	1676
query39	790	798	751	751
query39_1	741	741	733	733
query40	222	119	100	100
query41	74	71	70	70
query42	90	85	85	85
query43	348	368	313	313
query44	1321	696	725	696
query45	179	177	173	173
query46	840	974	573	573
query47	2935	2994	2762	2762
query48	304	306	223	223
query49	574	396	292	292
query50	673	273	209	209
query51	10477	10217	10484	10217
query52	80	87	70	70
query53	186	210	151	151
query54	231	193	173	173
query55	77	72	62	62
query56	236	207	223	207
query57	1639	1644	1567	1567
query58	282	267	261	261
query59	2154	2220	2000	2000
query60	272	240	213	213
query61	147	147	144	144
query62	384	338	283	283
query63	191	154	157	154
query64	2755	971	754	754
query65	3326	3296	3260	3260
query66	1785	420	297	297
query67	20227	20233	20028	20028
query68	2901	1001	613	613
query69	392	300	256	256
query70	848	789	752	752
query71	302	239	195	195
query72	2692	2592	2318	2318
query73	515	519	296	296
query74	4601	4514	4338	4338
query75	2325	2299	1934	1934
query76	2314	1015	583	583
query77	346	382	268	268
query78	9995	9694	9174	9174
query79	1009	898	527	527
query80	519	414	378	378
query81	531	317	269	269
query82	578	138	103	103
query83	295	204	206	204
query84	306	129	101	101
query85	809	423	367	367
query86	331	237	233	233
query87	2025	1945	1817	1817
query88	3795	2793	2774	2774
query89	334	283	248	248
query90	1876	169	156	156
query91	159	152	128	128
query92	103	91	79	79
query93	1008	985	575	575
query94	449	327	284	284
query95	578	351	363	351
query96	672	490	240	240
query97	2422	2439	2308	2308
query98	167	152	148	148
query99	766	759	664	664
Total cold run time: 234314 ms
Total hot run time: 151476 ms

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.10	0.05	0.04
query3	0.26	0.09	0.10
query4	1.61	0.10	0.09
query5	0.24	0.25	0.25
query6	1.18	0.68	0.68
query7	0.04	0.01	0.00
query8	0.05	0.04	0.03
query9	0.41	0.36	0.36
query10	0.60	0.58	0.58
query11	0.21	0.15	0.13
query12	0.19	0.16	0.15
query13	0.49	0.50	0.48
query14	1.02	1.02	1.00
query15	0.63	0.63	0.61
query16	0.32	0.36	0.37
query17	1.15	1.18	1.19
query18	0.22	0.20	0.19
query19	2.04	2.06	1.95
query20	0.02	0.02	0.01
query21	15.49	0.20	0.13
query22	4.90	0.06	0.05
query23	16.28	0.32	0.12
query24	2.75	0.44	0.52
query25	0.14	0.05	0.06
query26	0.80	0.22	0.17
query27	0.06	0.06	0.04
query28	3.29	0.83	0.39
query29	12.49	4.21	3.26
query30	0.28	0.13	0.09
query31	2.77	0.57	0.33
query32	3.23	0.61	0.51
query33	3.32	3.23	3.17
query34	15.44	4.04	3.38
query35	3.34	3.38	3.34
query36	0.57	0.46	0.43
query37	0.09	0.06	0.06
query38	0.06	0.04	0.04
query39	0.04	0.04	0.03
query40	0.17	0.16	0.14
query41	0.09	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 96.47 s
Total hot run time: 24.45 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 77.53% (36214/46709)
Line Coverage 62.77% (409406/652268)
Region Coverage 59.24% (346592/585082)
Branch Coverage 60.12% (160331/266689)

@liaoxin01
liaoxin01 merged commit bf58c2c into apache:master Oct 28, 2026
46 checks passed
@liaoxin01
liaoxin01 deleted the fix-packed-file-cache-write-switch branch October 28, 2026 03:56
yiguolei pushed a commit that referenced this pull request Nov 4, 2026
…ed small files #69693 (#70114)

### What problem does this PR solve?

Issue Number: None

Related PR: #69693

Problem Summary:

Backport #69693 to `branch-4.2`.

With packed files enabled, a load using `disable_file_cache=true` could
still populate the file cache because the packed writer ignored the
caller's option. Always propagate `FileWriterOptions::write_file_cache`
to the packed append context.

The test insertion conflict was resolved without importing the unrelated
nonzero-first-segment feature/test, which is absent on this branch.
Includes the cache-option unit test and preserves the original accessor
cleanup.

### Release note

Fix packed-file loads with `disable_file_cache=true` unexpectedly
populating the file cache.

### Check List (For Author)

- Test: clang-format 16 and `git diff --check` passed. BE unit tests are
included but were not run locally: the test entry point was blocked by
the Mac's unaccepted Xcode license. CI `run buildall` is requested
separately after PR creation.
- Behavior changed: Yes. Packed writes now honor the caller's file-cache
setting.
- Does this need documentation: No.
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.

5 participants