Skip to content

[fix](be) Restore file-level cache metadata loading during startup - #69116

Merged
deardeng merged 2 commits into
apache:masterfrom
deardeng:fix-load-file-cache
Oct 16, 2026
Merged

deardeng merged 2 commits into
apache:masterfrom
deardeng:fix-load-file-cache

Conversation

@deardeng

@deardeng deardeng commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Related PR: #57072, #65658

Problem Summary: During BE startup, get_or_set, the fully-covered lookup, and probe attempt to restore an absent file before background metadata loading completes. Their FileCacheKey leaves offset uninitialized, while the storage implementation now performs an exact RocksDB lookup for one block. A file with multiple persisted blocks can therefore miss existing cache data or restore only one block. Query metadata by tablet and file hash prefix, restore all blocks, and assert that the file hash is absent when entering synchronous restoration. Keep caller trigger conditions, key encoding, and existing tablet-range queries unchanged.

Fix reuse of persistent file cache blocks while BE startup metadata loading is in progress.

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:

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
  • 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

Related PR: apache#57072, apache#65658

Problem Summary: During BE startup, get_or_set, the fully-covered lookup, and probe attempt to restore an absent file before background metadata loading completes. Their FileCacheKey leaves offset uninitialized, while the storage implementation now performs an exact RocksDB lookup for one block. A file with multiple persisted blocks can therefore miss existing cache data or restore only one block. Query metadata by tablet and file hash prefix, restore all blocks, and assert that the file hash is absent when entering synchronous restoration. Keep caller trigger conditions, key encoding, and existing tablet-range queries unchanged.

Fix reuse of persistent file cache blocks while BE startup metadata loading is in progress.

- Test: Unit Test via run-be-ut.sh with ASAN and GLIBC_COMPATIBILITY=OFF: 38 related tests passed; 9 focused tests passed again after final cleanup. The 5 startup regression cases failed before the fix and passed afterward. clang-format v16, build hygiene, git diff checks, and clang-tidy on changed lines passed.
- Behavior changed: Yes, startup lookups restore all persisted blocks for an absent file instead of querying one uninitialized offset.
- Does this need documentation: No
@deardeng

Copy link
Copy Markdown
Contributor Author

run buildall

@deardeng

Copy link
Copy Markdown
Contributor Author

/review

@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?

@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 all 10 changed files at f8f8121 found no new actionable defects. The review converged in round 1: both complete-review agents and the separate startup-concurrency reviewer returned NO_NEW_VALUABLE_FINDINGS, and all initial risks were independently checked and disposed of. There are no existing inline threads or blocking comments to carry forward. No additional user focus was supplied.

Critical checkpoint conclusions:

  • Goal and evidence: all three absent-file startup lookups now restore the tablet/hash record range rather than one uninitialized offset. The added tests cover five paused-loader lookup cases, completed-startup gating, and file-prefix isolation. Their code and expectations were inspected; tests were not executed.
  • Scope and reuse: the changes are focused; shared prefix serialization serves full keys and both range-query variants.
  • Concurrency and locks: request lookups and background insertion serialize map/LRU/size updates with the cache mutex. Background merges retain duplicate handling. The absent-hash assertion follows from every caller's locked lookup. No new lock-order issue was found; the full scan and insertion remain inside the existing lock.
  • Lifecycle and static initialization: iterators own their copied prefix and are scoped within DB ownership. Loader/writer shutdown joins and drains existing work. Test callbacks resume before cache destruction. No new static initialization dependency or ownership cycle was found.
  • Configuration: no changes; dynamic propagation is not applicable.
  • Compatibility: persisted key bytes and value format remain unchanged, including high-bit hash fields. Internal interface declarations, implementations and callers are updated consistently; no new wire or rolling-upgrade incompatibility was identified.
  • Thrift/protobuf definitions: none changed; field-ID branch checks do not apply.
  • Parallel paths: get_or_set, fully-covered lookup and probe are covered; memory storage remains a no-op, and tablet-only TTL queries retain their behavior.
  • Conditions and errors: new missing-DB/malformed-record branches explain their concrete failure cases and match existing optional-cache recovery. The absent-file invariant is checked at restoration entry.
  • Test coverage: nonzero offsets, supported unaligned requests, multiple blocks, original metadata, missing/adjacent prefixes and completed-startup gating are covered by the added test code. These metadata-only startup tests do not read backing files or assert accounting after background loading resumes; runtime TTL, corruption, failure and latency behavior was not exercised.
  • Expected results: no golden result files were added or changed; inspected unit-test expectations match the intended metadata behavior.
  • Observability: existing lookup/probe timing and warning paths cover restoration; no per-block INFO logging was introduced.
  • Persistence and failover: local cache serialization and asynchronous write/delete semantics are preserved. No transaction, EditLog, FE failover or authoritative-data persistence logic changes.
  • Writes and crash behavior: restoration rebuilds cache state through the existing insertion/normalization path. Existing pending-delete/background-snapshot limitations are not introduced by this change; no distinct new atomicity or crash defect was established.
  • FE/BE variables: none added; no propagation path is affected.
  • Performance: restoration costs one seek plus O(blocks in this file) work under the existing cache mutex, as required for whole-file restoration. No concrete excessive-work failure or new deadlock was established; large-file latency was not measured.
  • Other invariants: no new authoritative visibility, version or delete-bitmap behavior, ownership issue, header-hygiene mechanism, source-.cpp test inclusion or glibc dependency was identified. Normal, fully-covered and probe-based reads retain remote fallback on local cache errors.

This was static inspection only: no builds, tests, source modifications or runtime experiments were performed. All changed-file review scope is covered; runtime behavior beyond the inspected paths remains unverified.

Review converged after 1 round(s).

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17586	5691	5603	5603
q2	2082	314	283	283
q3	10217	1430	848	848
q4	4686	475	345	345
q5	7439	806	540	540
q6	190	190	164	164
q7	774	806	613	613
q8	9253	1365	1098	1098
q9	5548	4348	4304	4304
q10	6829	1327	1038	1038
q11	439	270	252	252
q12	640	402	306	306
q13	18078	3605	3032	3032
q14	280	266	252	252
q15	q16	747	728	689	689
q17	1198	748	596	596
q18	7026	6259	6193	6193
q19	1106	954	626	626
q20	404	345	234	234
q21	5433	2576	2654	2576
q22	431	358	300	300
Total cold run time: 100386 ms
Total hot run time: 29892 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	6610	6604	6473	6473
q2	747	603	593	593
q3	5473	5694	5199	5199
q4	2122	2183	1887	1887
q5	5881	5666	5647	5647
q6	245	188	150	150
q7	2339	2065	1865	1865
q8	3168	2875	2824	2824
q9	8046	8051	7561	7561
q10	3697	3605	3255	3255
q11	612	437	385	385
q12	671	689	506	506
q13	3324	3615	3002	3002
q14	300	291	262	262
q15	q16	674	697	624	624
q17	7839	7079	6874	6874
q18	13235	12303	13141	12303
q19	969	846	839	839
q20	2201	2176	1948	1948
q21	6023	5030	5036	5030
q22	516	454	417	417
Total cold run time: 74692 ms
Total hot run time: 67644 ms

### What problem does this PR solve?

Issue Number: None

Problem Summary: Peer cache requests carried a tablet ID in rowset_meta, but
the server left CacheContext.tablet_id at zero. During startup, lazy cache
restoration therefore queried the wrong metadata prefix and missed persisted
blocks. Pass the supplied tablet ID to get_or_set while preserving the zero
default for older clients that omit rowset_meta. Cover both request versions
with a restart test, and verify that background restoration preserves cache
accounting and the block objects already restored synchronously.

### Release note

Peer reads can restore persisted cache blocks under the requested tablet
before background cache loading finishes.

### Check List (For Author)

- Test: Unit Test
    - Reproduced the peer startup miss before the fix; the legacy request passed.
    - Passed 65 related ASAN unit tests using run-be-ut.sh, including peer
      reads, cache metadata, all five lazy-restore cases, and both peer
      startup request versions.
    - Passed clang-format v16, check-format, build hygiene, and git diff --check.
    - clang-tidy: no diagnostics on modified source lines; test checks passed.
      The existing peer handler cognitive-complexity warning remains (58 > 50).
    - Used GLIBC_COMPATIBILITY=OFF for the local unit-test link, as in the
      preceding cache restoration validation; no production build options changed.
- Behavior changed: Yes; peer requests use their supplied tablet ID for cache restoration.
- Does this need documentation: No
@hello-stephen

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

query5	4309	582	488	488
query6	435	215	198	198
query7	4817	460	239	239
query8	320	180	163	163
query9	8757	4043	4080	4043
query10	490	321	277	277
query11	5936	3829	3548	3548
query12	149	91	85	85
query13	1260	469	356	356
query14	6138	4069	3809	3809
query14_1	3632	3583	3573	3573
query15	210	196	178	178
query16	942	458	428	428
query17	869	665	544	544
query18	2430	438	323	323
query19	210	168	141	141
query20	89	87	84	84
query21	211	134	115	115
query22	13016	13069	12960	12960
query23	13519	12865	12462	12462
query23_1	12685	12545	12595	12545
query24	7083	859	467	467
query24_1	472	474	487	474
query25	547	428	370	370
query26	1314	269	140	140
query27	2733	444	275	275
query28	4587	1974	1993	1974
query29	1579	619	491	491
query30	307	225	188	188
query31	1014	934	808	808
query32	143	99	91	91
query33	514	316	282	282
query34	899	862	503	503
query35	741	763	650	650
query36	845	801	701	701
query37	133	99	84	84
query38	1801	1737	1662	1662
query39	793	816	751	751
query39_1	739	730	746	730
query40	220	111	100	100
query41	69	64	64	64
query42	84	82	81	81
query43	360	388	330	330
query44	1337	694	713	694
query45	191	195	160	160
query46	872	971	563	563
query47	2765	2966	2931	2931
query48	297	323	222	222
query49	585	403	305	305
query50	700	282	221	221
query51	10493	10651	10364	10364
query52	80	82	70	70
query53	187	209	156	156
query54	238	199	178	178
query55	69	69	64	64
query56	242	215	211	211
query57	1619	1579	1562	1562
query58	286	268	261	261
query59	2086	2202	1923	1923
query60	279	254	216	216
query61	155	146	147	146
query62	397	336	290	290
query63	200	165	161	161
query64	2786	979	800	800
query65	3309	3241	3225	3225
query66	1790	437	309	309
query67	20136	20152	20058	20058
query68	2905	1024	616	616
query69	385	287	246	246
query70	872	805	780	780
query71	307	237	205	205
query72	2744	2634	2251	2251
query73	535	543	300	300
query74	4598	4477	4335	4335
query75	2371	2315	1945	1945
query76	2308	1026	604	604
query77	358	369	285	285
query78	9629	9670	9158	9158
query79	879	922	538	538
query80	552	449	353	353
query81	531	325	276	276
query82	477	141	109	109
query83	298	201	186	186
query84	323	135	106	106
query85	866	438	376	376
query86	320	252	229	229
query87	2012	1992	1835	1835
query88	3684	2696	2698	2696
query89	336	302	254	254
query90	1808	188	186	186
query91	172	156	126	126
query92	103	93	92	92
query93	1054	1033	588	588
query94	460	315	292	292
query95	592	354	332	332
query96	686	547	237	237
query97	2462	2428	2308	2308
query98	158	155	147	147
query99	790	767	664	664
Total cold run time: 233848 ms
Total hot run time: 152839 ms

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.09	0.05	0.05
query3	0.26	0.12	0.12
query4	1.61	0.12	0.13
query5	0.25	0.25	0.25
query6	1.17	0.68	0.68
query7	0.03	0.01	0.00
query8	0.05	0.03	0.03
query9	0.40	0.37	0.35
query10	0.58	0.58	0.56
query11	0.22	0.14	0.14
query12	0.18	0.15	0.15
query13	0.51	0.50	0.49
query14	1.02	1.02	1.00
query15	0.66	0.62	0.62
query16	0.35	0.35	0.36
query17	1.13	1.15	1.12
query18	0.23	0.22	0.22
query19	2.09	2.04	1.93
query20	0.02	0.01	0.01
query21	15.42	0.28	0.15
query22	4.43	0.06	0.05
query23	16.26	0.33	0.12
query24	2.68	1.18	0.59
query25	0.11	0.06	0.06
query26	1.86	0.26	0.14
query27	0.03	0.04	0.03
query28	2.27	0.60	0.40
query29	12.51	4.12	3.32
query30	0.30	0.14	0.13
query31	2.76	0.57	0.34
query32	3.22	0.62	0.52
query33	3.29	3.20	3.23
query34	15.50	4.02	3.39
query35	3.36	3.35	3.36
query36	0.56	0.50	0.44
query37	0.10	0.06	0.07
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.14	0.14
query41	0.08	0.04	0.02
query42	0.04	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 95.94 s
Total hot run time: 24.78 s

@deardeng

Copy link
Copy Markdown
Contributor Author

run buildall

@liaoxin01 liaoxin01 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.

LGTM

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17587	5656	5588	5588
q2	2119	294	243	243
q3	10257	1456	856	856
q4	4676	472	341	341
q5	7445	781	533	533
q6	193	204	155	155
q7	776	816	594	594
q8	9248	1330	1136	1136
q9	5491	4313	4285	4285
q10	6809	1297	1033	1033
q11	440	260	244	244
q12	637	445	289	289
q13	18060	3519	2997	2997
q14	277	270	248	248
q15	q16	719	726	676	676
q17	1178	752	565	565
q18	7076	6234	6191	6191
q19	1113	953	633	633
q20	386	341	228	228
q21	5146	2292	2444	2292
q22	369	316	258	258
Total cold run time: 100002 ms
Total hot run time: 29385 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	6177	6154	6191	6154
q2	719	589	557	557
q3	5240	5387	4935	4935
q4	2025	2114	1544	1544
q5	5269	5447	5780	5447
q6	267	199	157	157
q7	2326	2054	1898	1898
q8	3209	2815	2821	2815
q9	8024	8137	8227	8137
q10	3822	3726	3330	3330
q11	654	444	406	406
q12	718	757	598	598
q13	3704	3845	3352	3352
q14	338	338	286	286
q15	q16	702	711	638	638
q17	8536	7720	7112	7112
q18	13176	12277	13115	12277
q19	979	851	842	842
q20	2207	2170	1939	1939
q21	5897	4737	4835	4737
q22	500	452	417	417
Total cold run time: 74489 ms
Total hot run time: 67578 ms

@hello-stephen

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

query5	4296	582	443	443
query6	416	222	190	190
query7	4812	441	220	220
query8	317	166	153	153
query9	8742	3943	3938	3938
query10	465	297	257	257
query11	6047	3786	3510	3510
query12	146	95	89	89
query13	1255	446	318	318
query14	6063	4027	3789	3789
query14_1	3536	3507	3573	3507
query15	205	195	175	175
query16	926	448	402	402
query17	820	629	520	520
query18	2406	405	295	295
query19	194	155	129	129
query20	81	85	82	82
query21	206	128	108	108
query22	13047	13199	12794	12794
query23	13429	12904	12570	12570
query23_1	12600	12691	12683	12683
query24	7102	818	464	464
query24_1	466	468	469	468
query25	510	388	349	349
query26	1268	249	137	137
query27	2795	431	269	269
query28	4632	1937	1947	1937
query29	1562	581	454	454
query30	293	222	183	183
query31	1005	929	815	815
query32	146	98	93	93
query33	524	308	247	247
query34	902	854	503	503
query35	757	774	652	652
query36	829	820	730	730
query37	134	100	123	100
query38	1816	1757	1665	1665
query39	787	793	748	748
query39_1	732	735	735	735
query40	214	112	91	91
query41	67	63	63	63
query42	82	82	79	79
query43	361	386	324	324
query44	1288	684	696	684
query45	176	169	164	164
query46	870	953	567	567
query47	2911	3022	2920	2920
query48	295	297	212	212
query49	575	400	297	297
query50	689	279	219	219
query51	10616	10487	10656	10487
query52	77	86	74	74
query53	187	208	150	150
query54	245	196	184	184
query55	68	68	59	59
query56	241	207	203	203
query57	1620	1577	1535	1535
query58	278	261	251	251
query59	2148	2123	1977	1977
query60	291	238	218	218
query61	143	143	145	143
query62	399	341	285	285
query63	197	161	167	161
query64	2724	894	787	787
query65	3279	3221	3217	3217
query66	1783	410	306	306
query67	20105	20035	19948	19948
query68	2948	1033	608	608
query69	382	287	252	252
query70	857	794	766	766
query71	294	221	206	206
query72	2693	2558	2271	2271
query73	505	527	335	335
query74	4614	4456	4304	4304
query75	2332	2295	1948	1948
query76	2307	1015	605	605
query77	333	382	266	266
query78	9632	9601	9100	9100
query79	886	837	515	515
query80	488	422	349	349
query81	516	325	278	278
query82	209	128	105	105
query83	197	196	183	183
query84	289	126	100	100
query85	757	424	383	383
query86	258	244	233	233
query87	2023	1949	1807	1807
query88	3657	2742	2712	2712
query89	337	293	254	254
query90	2120	183	179	179
query91	160	152	140	140
query92	99	87	93	87
query93	994	991	585	585
query94	438	294	266	266
query95	595	358	319	319
query96	659	516	234	234
query97	2509	2470	2332	2332
query98	161	150	147	147
query99	793	754	648	648
Total cold run time: 233018 ms
Total hot run time: 152119 ms

@hello-stephen

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

query1	0.01	0.00	0.01
query2	0.10	0.04	0.05
query3	0.26	0.12	0.12
query4	1.62	0.13	0.13
query5	0.28	0.24	0.25
query6	1.17	0.69	0.69
query7	0.04	0.01	0.01
query8	0.06	0.04	0.04
query9	0.41	0.36	0.36
query10	0.57	0.59	0.58
query11	0.21	0.14	0.14
query12	0.19	0.14	0.15
query13	0.49	0.48	0.50
query14	1.02	1.02	1.00
query15	0.63	0.60	0.61
query16	0.35	0.32	0.34
query17	1.16	1.13	1.13
query18	0.22	0.21	0.21
query19	2.10	1.88	1.95
query20	0.02	0.02	0.01
query21	15.48	0.26	0.14
query22	4.54	0.05	0.05
query23	16.29	0.32	0.12
query24	3.02	0.80	0.38
query25	0.10	0.06	0.05
query26	1.42	0.25	0.15
query27	0.05	0.04	0.03
query28	2.04	0.59	0.38
query29	12.46	4.26	3.34
query30	0.28	0.14	0.13
query31	2.77	0.58	0.34
query32	3.22	0.61	0.52
query33	3.16	3.18	3.20
query34	15.38	4.03	3.40
query35	3.33	3.38	3.36
query36	0.56	0.42	0.46
query37	0.09	0.06	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.15	0.13
query41	0.08	0.03	0.03
query42	0.03	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 95.51 s
Total hot run time: 24.46 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 0.00% (0/1) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.05% (35647/46264)
Line Coverage 62.36% (403955/647750)
Region Coverage 58.68% (340608/580497)
Branch Coverage 59.66% (157185/263488)

@gavinchou

Copy link
Copy Markdown
Contributor

/review

@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.

Reviewed all 12 changed files at b562478 and their relevant callers, persistence paths, startup workers and tests. No verified newly introduced defect was found. There are no existing inline comments or independently confirmed existing P0/P1 findings. No additional user focus was supplied.

The review converged after round 1: both complete-scope reviewers and the separate startup-risk reviewer returned NO_NEW_VALUABLE_FINDINGS, all investigated concerns have evidence-backed dispositions, and the main final sweep found no uncovered changed file or unresolved candidate.

Critical checkpoint conclusions:

  1. Goal and evidence: The new tablet/hash prefix lookup removes dependence on an uninitialized offset and restores all persisted blocks for that identity in each of the three absent-file startup lookup APIs. Added tests inspect both nonzero offsets, preserved metadata, completed-startup bypass and actual peer-returned bytes. These tests were read, not executed.
  2. Scope and reuse: The change is focused. Shared prefix encoding is reused by serialization and range lookup; all renamed storage overrides and callers are consistent.
  3. Concurrency and locks: Foreground lookup holds the cache mutex throughout the missing-hash check and direct restoration. Background loading scans outside that mutex and merges under it using the existing per-offset deduplication. The absent-hash assertion is supported by the callers. No introduced lock-order inversion was found. Full-file RocksDB work remains inside the existing cache critical section.
  4. Lifecycle and memory: Iterators have local ownership; storage outlives synchronous scans and joins the background loader during destruction. Existing FileBlock/LRU ownership and accounting are reused. Test cleanup resumes paused loaders before destroying caches. No new cross-translation-unit initialization dependency or ownership cycle was found.
  5. Configuration: No configuration items or dynamic-update behavior were added.
  6. Compatibility: Persisted key bytes, version, value encoding and the existing tablet-wide range API are unchanged. The internal virtual-method rename updates both storage implementations. Optional peer metadata is read without changing the RPC schema; missing metadata retains tablet zero.
  7. Thrift/protobuf IDs: No definition changes; cross-branch field-ID comparison is not applicable.
  8. Parallel paths: get_or_set, fully-covered lookup, probe, filesystem and memory storage, peer reads, fill, and the tablet-wide TTL consumer were inspected. Existing startup trigger conditions remain unchanged. Peer identity limitations below are pre-existing.
  9. Conditional checks and errors: The assertion reflects a locked invariant. Null iterator handling corresponds to database initialization failure, and decode checks follow background-loader practice. No newly introduced silent-success failure path was established.
  10. Test coverage: New unit scenarios cover neighboring file/tablet prefixes, misses, aligned and unaligned non-probe reads, aligned probe, cache type/size/tablet preservation, background merge identity/accounting, completed-open skip, and peer requests with/without metadata. No cluster, corruption, TTL, upgrade or large-file performance test was executed.
  11. Expected results: No golden/result files changed. Added assertions agree with the inspected API behavior and fixture lifecycle.
  12. Observability: Existing lookup/probe/peer latency and cache counters cover the modified calls; iterator/decoding failures are logged. No additional critical observability requirement was established.
  13. Persistence and failover: This changes cache recovery reads. Serialization, async metadata writes and durable finalize/delete ordering are unchanged; no EditLog, transaction protocol or FE failover logic is involved.
  14. Writes and crash atomicity: Cache metadata publication remains serialized by the cache mutex. Existing stale-snapshot and asynchronous deletion windows were traced and were not established as new regressions.
  15. FE/BE variables: None added; the peer handler consumes the existing optional rowset metadata.
  16. Performance: A prefix seek streams only the selected file's records, with O(file blocks) cell restoration and no second full-file collection. Startup mutex latency and memory cost were not measured; no concrete new performance defect was verified.
  17. Other invariants and BE checks: No new transaction visibility, delete-bitmap, nullable-column, libc/linker, PCH, template-family or source-inclusion change. The read-only build-support/check-build-hygiene.sh check passed for header hygiene, extern-template pairing and unity skip coverage.

Limits: This was a static code review with no builds or functional tests. Historical peer-filled tablet-zero records can still miss a positive-tablet synchronous scan, and the unchanged sequential peer helper still defaults its outgoing tablet ID to zero. The patch does not migrate those keys or repair that sender; the old startup point lookup was already unreliable. Partial background loading and stale metadata windows also predate this patch. The added matching-identity tests do not prove recovery across those identity mismatches. These are documented existing limits, not unresolved introduced-defect candidates or new inline findings.

Review converged after 1 round(s).

@deardeng
deardeng merged commit e9b3373 into apache:master Oct 16, 2026
38 of 39 checks passed
bobhan1 pushed a commit to bobhan1/doris that referenced this pull request Nov 6, 2026
…pache#69116)

Related PR: apache#57072, apache#65658

Problem Summary: During BE startup, get_or_set, the fully-covered
lookup, and probe attempt to restore an absent file before background
metadata loading completes. Their FileCacheKey leaves offset
uninitialized, while the storage implementation now performs an exact
RocksDB lookup for one block. A file with multiple persisted blocks can
therefore miss existing cache data or restore only one block. Query
metadata by tablet and file hash prefix, restore all blocks, and assert
that the file hash is absent when entering synchronous restoration. Keep
caller trigger conditions, key encoding, and existing tablet-range
queries unchanged.

Fix reuse of persistent file cache blocks while BE startup metadata
loading is in progress.

(cherry picked from commit e9b3373)
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