morningman opened a new pull request, #71328:
URL: https://github.com/apache/doris/pull/71328

   ### Background
   
   The BE file cache keeps local file readers in an LRU cache and runs separate 
threads for TTL maintenance and stale-file cleanup. Local storage engines send 
cooldown metadata to remote storage so other replicas can follow it. Several 
storage-engine tests share process-wide caches keyed by rowset ID.
   
   ### What problem does this PR solve?
   
   Issue Number: #71314
   Related PR: #57922 (TTL manager), #59269 (leak cleaner), #21975 (file-reader 
cache), #16813 (async cooldown metadata upload), #1678 (rowset ID generator), 
#68436 (cloud test workaround)
   PR Type: Bugfix
   
   Problem Summary: File cache workers can delay shutdown. Cooldown writers can 
use destroyed state or retry failed uploads in a tight loop. Engines using 
default options can read each other's cached segments. After filling the FD 
cache with four readers and lowering the limit to two, the next insertion used 
to grow the cache to five readers. It now leaves two.
   
   ### Details
   
   - **Change map:** 122 production lines and 370 test lines changed across 
nine commits. The changes below list each commit in review order.
   
     | Commit | Purpose |
     | --- | --- |
     | Wake TTL manager threads | Interrupt interval and exception waits on 
shutdown. |
     | Join cooldown metadata writers | Keep executor state alive through 
worker exit. |
     | Tear down the cooldown fixture | Release its executors before destroying 
its engine and storage policy. |
     | Shrink the FD cache | Evict to the new limit on the next insertion of a 
new key. |
     | Give default engines distinct backend UIDs | Prevent rowset ID 
collisions and use the actual output rowset IDs in the index tests. |
     | Reject negative FD cache capacity | Validate the value at startup and on 
runtime updates. |
     | Synchronize leak-cleaner stop | Close the lost-notification window 
before a condition-variable wait. |
     | Defer failed cooldown writes | Resubmit failed tablets from the next 
cooldown round. |
     | Isolate cache settings in tests | Keep the cooldown mock independent of 
the file cache and remove scan interval writes from synchronous tests. |
   
   - **Frequency:** TTL stops stall during interval waits. Leak-cleaner and 
executor shutdown failures depend on thread scheduling. Any new key inserted 
into an over-capacity FD cache triggers the eviction bug. Persistent 
non-`ABORTED` cooldown failures trigger immediate retries. Default-option 
engines generate matching IDs at equal sequence positions.
   - **Root cause:** The TTL manager used uninterruptible sleeps, and the leak 
cleaner published its stop flag outside the wait mutex. FD cache eviction 
tested for equality against the limit. Cooldown workers used members after 
their destruction started and requeued themselves on failure. Default engine 
options used an all-zero backend UID.
   - **Why existing tests missed it:** The TTL and leak-cleaner tests used 
short waits. FD cache tests set a valid limit before filling the cache. 
`TabletCooldownTest` checked results without controlling teardown or counting 
retries. Rowset ID tests used explicit UIDs. Cold-data and storage-policy 
regression suites run successful cooldown against reachable storage.
   - **Fix:** Use interruptible waits and publish stops under the wait mutexes. 
Evict LRU readers until the new key fits, and validate the limit. Join cooldown 
writers while their state is alive and retry through the producer. Generate an 
independent UID for default engine options.
   - **Other paths and branches:** Both leak-cleaner waits use the same 
predicate. The cooldown retry change applies to local storage. The TTL and 
leak-cleaner bugs are present in 4.1 and 4.2. The FD config, cooldown retry and 
default UID code are also present in 3.1 and 4.0. Production BE startup already 
sets an explicit UID.
   - **Configs and defaults:** `file_cache_max_file_reader_cache_size` stays 
mutable and defaults to `1000000`. Valid values are zero (disabled) and 
positive capacities.
   - **Behavior change:** A negative FD cache limit now fails startup 
validation or returns an error from a runtime update. A failed cooldown upload 
is retried on the next producer round (20 seconds by default), and dropped 
tablets are skipped.
   
   ### Testing
   
   - Pre-fix regressions caught the blocked shutdowns, repeated cooldown 
retries, a cache growing past its new limit, acceptance of negative capacities, 
and equal rowset IDs across default engines.
   - Standalone macOS ASAN `run-be-ut.sh --run -j 6` ran 288 cases. 
Registration order had 285 passes and 3 skips. Shuffle seed 48256 had 283 
passes, the same 3 skips, and two existing test-isolation failures tracked in 
#71314: `BlockFileCacheTest.fd_cache_remove` and 
`BlockFileCacheTest.reader_dryrun_when_download_file_cache`. All new 
regressions passed in both runs.
   
   ### Release note
   
   Idle file cache workers wake promptly on BE shutdown. The file-reader cache 
shrinks to a lowered positive limit on the next insertion of a new key. Correct 
negative `file_cache_max_file_reader_cache_size` settings before upgrading. 
Failed cooldown metadata uploads retry on a subsequent cooldown round.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: Yes. Update the BE configuration reference 
in apache/doris-website to document positive capacities and zero as the 
disabled setting.
   - Pre-submission status: Partially verified: Linux CI pending. Two existing 
order-dependent file-cache tests fail when shuffled.
   
   ### AI Disclosure
   
   - Tool: Claude Code (Claude Opus 5.5), OpenAI Codex (GPT-6)
   - Generated: Original fixes and tests by Claude Code. Standalone test 
adaptations and PR description by Codex.
   - Human review: not stated
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to