Skip to content

branch-4.1: [fix](filecache) Unify the file cache TTL deadline across all paths - #68313

Open
liaoxin01 wants to merge 1 commit into
apache:branch-4.1from
liaoxin01:codex/pick-68090-to-branch-4.1
Open

liaoxin01 wants to merge 1 commit into
apache:branch-4.1from
liaoxin01:codex/pick-68090-to-branch-4.1

Conversation

@liaoxin01

Copy link
Copy Markdown
Contributor

Pick #68090

@liaoxin01
liaoxin01 requested a review from yiguolei as a code owner September 21, 2026 06:29
@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?

…pache#68090)

### What problem does this PR solve?

Related PR: apache#57922

Problem Summary:

apache#57922 moved file cache TTL management from block granularity to tablet
granularity. As part of that change every path stopped computing an
expiration
timestamp and started passing the raw ttl_seconds instead:

    expiration_time = tablet_meta->ttl_seconds();

The receiving side was never updated. KeyMeta::expiration_time still
documents
itself as an absolute time, and that value is what gets persisted into
the block
meta store and compared by the cache consistency check. Those fields now
hold a
duration such as 3600 rather than a timestamp, so the only information
left in
them is "non-zero means this is a TTL block".

Meanwhile the expiration decision itself moved into
BlockFileCacheTtlMgr, which
sweeps by tablet_ctime + ttl < now, anchored at the tablet creation
time.

Two consequences:

1. Blocks are created as TTL blocks regardless of whether the tablet is
still
within its TTL window. Once a tablet is past creation_time +
ttl_seconds, the
load, compaction and query paths keep putting blocks into the TTL queue
and
the background sweep keeps pulling them straight back out. Each
conversion
writes the block meta store and takes the cache lock to move the block
   between LRU queues, and the loop never terminates for the rest of the
   tablet's life.

2. The two writer paths disagreed with each other. The packed file path
in
RowsetWriterContext still computed an absolute newest_write_timestamp +
ttl,
while the regular file writer path passed the relative ttl_seconds, so
segment files and packed small files of the same rowset were stamped
with
different kinds of value. check_file_cache_consistency reports that as
   EXPIRATION_TIME_INCONSISTENT.

This PR keeps the tablet creation time as the anchor and gives that
deadline a
single definition, TabletMeta::file_cache_ttl_expiration_time(), which
returns
the absolute creation_time + ttl_seconds, or 0 when the tablet has no
TTL or is
already past the deadline. The load, compaction, schema change, query
and warm
up paths all stamp the blocks they create with that value, so a block's
recorded
expiration time now agrees with the sweep that acts on it, and a tablet
past its
deadline has its blocks created as NORMAL directly instead of cycling
through
the TTL queue.

BlockFileCacheTtlMgr additionally no longer promotes the blocks of an
already
expired tablet on the edge where it first sees that tablet, which
previously
caused one full promote/demote pass per TTL tablet after every BE
restart.

The existing regression tests could not catch this: they all create a
table and
load into it immediately, so the tablet creation time and the data write
time
coincide and the bug is invisible.

### Release note

Fixed the file cache TTL expiration time being computed inconsistently
across
the load, compaction, query and warm up paths. Data belonging to a
tablet that
is past its TTL deadline is now written directly into the normal cache
queue
instead of repeatedly entering and leaving the TTL queue.
@liaoxin01
liaoxin01 force-pushed the codex/pick-68090-to-branch-4.1 branch from d7f79aa to b7b0df5 Compare September 21, 2026 06:30
@liaoxin01

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 76.00% (19/25) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 59.90% (26007/43418)
Line Coverage 44.66% (268869/602010)
Region Coverage 40.49% (213238/526636)
Branch Coverage 41.99% (98593/234800)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 88.46% (23/26) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.39% (31426/42243)
Line Coverage 58.66% (350352/597220)
Region Coverage 55.40% (292403/527834)
Branch Coverage 56.27% (131983/234540)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants