branch-4.1: [fix](filecache) convert blocks back to TTL when an expired TTL is extended #67971 - #68092
Open
github-actions[bot] wants to merge 1 commit into
Open
branch-4.1: [fix](filecache) convert blocks back to TTL when an expired TTL is extended #67971#68092github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…tended (#67971) ### What problem does this PR solve? Issue Number: None Related PR: None Problem Summary: `BlockFileCacheTtlMgr` decided whether to promote a tablet's cached blocks into the TTL queue from `was_zero_ttl`, which is true only when `_ttl_info_map` holds no entry for the tablet. Since the entry is erased only when the tablet's TTL is zero, that flag really answers "has this BE ever seen a non-zero TTL here", not "are the blocks outside the TTL queue". The expiration check demotes blocks back to NORMAL but leaves the non-zero TTL in the map. So once a TTL expired, the promotion path was closed for that tablet for good: extending the expired TTL to a value that has not expired updated FE, Meta Service and `_ttl_info_map`, yet the blocks stayed in the normal queue and no later round ever brought them back. They were then evicted under the normal policy while `SHOW CREATE TABLE` and `information_schema.file_cache_info` disagreed about whether TTL applied. Nothing was logged, because the conversion was never attempted. ### Release note Fixed cached blocks staying out of the TTL queue when a table's expired `file_cache_ttl_seconds` is extended to a value that has not expired. ### What is changed and how it works? **1. Record what was applied instead of inferring it.** `TtlInfo` carries `blocks_promoted` — true once this manager has put the tablet's blocks into the TTL queue and nothing has taken them out since. It records what the manager did, not what the blocks are, so it starts false for a tablet seen for the first time after a restart, whose blocks on disk may well be TTL already. **2. Skip only when the TTL is still running and the blocks are already promoted.** The two directions are not symmetric: - *Promotion is edge triggered.* Once the blocks are in the TTL queue nothing takes them out behind our back, so rescanning a tablet whose TTL is still running is pure waste. This is also what makes a TTL rewritten to another still-valid value free, which matters where the property is rewritten on a schedule — the decision is a state comparison, not a comparison of TTL values. - *Demotion is level triggered.* Blocks can still land in the TTL queue after a tablet was demoted, and `blocks_promoted` is per tablet, so it cannot tell whether any have. Rescanning is the only way to collect them. | TTL state | `blocks_promoted` | action | |---|---|---| | running | true | skip | | running | false | scan, promote | | expired / none | true | scan, demote | | expired | false | scan, demote | | none | false | stop tracking the tablet | **3. Serialize transitions per tablet.** Both background threads funnel through `reconcile_tablet_blocks()`, serialized by a striped lock, re-reading the tablet's state after taking it. The expiration check previously decided from a snapshot of `_ttl_info_map` that could be a full gc interval old, so it could demote blocks the update thread had just promoted under a newly extended TTL, and neither thread would touch them again. Its snapshot is now only a candidate list. **4. Do not hold `_ttl_info_mutex` across the block scan.** It walks the meta store and takes the cache lock once per block, which on a tablet with a few thousand cached blocks blocked every other user of the map for the duration. **5. A failed conversion does not record success.** `change_cache_type()` rewrites storage metadata and can fail; recording the new state anyway left the tablet permanently mismatched, because every later round then saw state and wants agreeing. `blocks_promoted` is left alone unless every block converted, so the next round retries. **6. Stop tracking a tablet that has settled.** A tablet with no TTL whose blocks are not in the TTL queue is dropped from the map before the transition check, so one that settles without needing a conversion still stops being walked on every round. Adds a `file_cache_ttl_mgr_ttl_info_map_size` bvar and an INFO line naming the tablet, direction and block count on each conversion.
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
Contributor
|
run buildall |
Contributor
BE Regression && UT Coverage ReportIncrement line coverage Increment coverage report
|
yiguolei
approved these changes
Sep 17, 2026
Contributor
Author
|
PR approved by anyone and no changes requested. |
Contributor
Author
|
PR approved by at least one committer and no changes requested. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-picked from #67971