[server] local segment ttl#3623
Conversation
There was a problem hiding this comment.
Pull request overview
This PR wires the table-level table.log.ttl setting into server-side LogTablet creation and uses it to expire tier-protected inactive local log segments (kept for tiered storage) once they exceed TTL, with a new remote-log-focused regression test. It also adjusts a Flink IT base test to use a unique database name per test run.
Changes:
- Pass table log TTL (ms) through
Replica→LogManager→LogTabletand use it when deciding whether tier-protected inactive local segments are deletable. - Invoke local cleanup of “already copied to remote” segments on every remote retention pass (not only when the remote end offset increases).
- Add
TieredLocalSegmentTtlTestand make Flink batch ITs use per-test database names.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| fluss-server/src/test/java/org/apache/fluss/server/log/remote/TieredLocalSegmentTtlTest.java | New test covering TTL-driven cleanup of tier-protected inactive local segments in tiered storage setups. |
| fluss-server/src/main/java/org/apache/fluss/server/replica/Replica.java | Plumbs table log TTL into log creation path. |
| fluss-server/src/main/java/org/apache/fluss/server/log/LogTablet.java | Adds TTL awareness to local deletable-segment selection and runs remote-copied local cleanup on each retention pass. |
| fluss-server/src/main/java/org/apache/fluss/server/log/LogManager.java | Extends getOrCreateLog/loadLog creation to pass TTL into LogTablet. |
| fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/source/FlinkTableSourceBatchITCase.java | Uses a randomized database name and updates expectations accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Try to delete segments that have already existed in remote storage on every retention | ||
| // pass. A remote TTL cleanup may leave the manifest end offset unchanged or decrease it, | ||
| // but locally retained inactive segments may have expired in the meantime. | ||
| deleteSegmentsAlreadyExistsInRemote(); | ||
| } |
There was a problem hiding this comment.
It is an existing edge case which may not trigger deleteSegmentsAlreadyExistsInRemote (no matter newly added TTL or existing local-segment file counts).
I'd suggest to handle this in another issue.
|
Hi, @gyang94 I don't think local TTL cleanup should be coupled with remote log manifest updates. Local TTL is part of the local log's retention semantics, so it would be better to run it as a periodic task in |
swuferhong
left a comment
There was a problem hiding this comment.
Thanks for your contribution. I left some comments.
swuferhong
left a comment
There was a problem hiding this comment.
LGTM +1. Hi @wuchong could you take a look?
zuston
left a comment
There was a problem hiding this comment.
Thanks for working on this. After reviewing the changes, I have a couple of questions:
- Without this PR, if we set table.log.tiered.local-segments = 1, would that achieve the same goal as this PR?
- It looks like this PR does not roll the active segment for historical/inactive partitions.
Hi, @zuston. Based on the offline discussion with @gyang94 , implementing TTL for the active segment in the short term is fairly tricky and requires a detailed design—but that doesn't mean it shouldn't be done. You can continue working on this in a follow-up PR. Regarding whether it can be set to |
|
thanks for your quick reply. @swuferhong
make sense if setting the large number of local segments reservation. |
Because Fluss remote currently lacks column pruning capability, many users will still choose to configure |
OK. I also want to cut off the storage cost for the long-term historical partition. |
Purpose
Linked issue: close #xxx
Brief change log
Tests
API and Format
Documentation