[server] Roll expired active segments for remote retention - #3831
Open
fxbing wants to merge 3 commits into
Open
Conversation
- Roll non-empty expired active segments after TTL once the high watermark reaches the log end offset. - Preserve contiguous inactive-segment boundaries and defer deletion until remote upload completes. - Cover partitioned and non-partitioned retention behavior, including disabled TTL and remote log settings.
fxbing
marked this pull request as ready for review
August 3, 2026 09:36
gyang94
reviewed
Aug 3, 2026
- Roll expired non-empty active segments after all preceding segments pass retention checks and the high watermark reaches LEO. - Preserve two-pass retention and cover true remote-disabled and empty-active behavior.
gyang94
approved these changes
Aug 5, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses #3830 by ensuring periodic TTL-based local retention can roll a non-empty, TTL-expired active log segment (once highWatermark >= logEndOffset), making the segment eligible for subsequent remote upload and later local cleanup.
Changes:
- Update
LogTabletTTL retention logic to potentially roll an expired active segment (and narrowroll(...)tothrows IOException). - Extend tiered-storage TTL tests to cover active-segment roll behavior, high-watermark gating, remote end-offset boundaries, TTL disabled, and empty-active-segment behavior.
- Add a new non-tiered TTL test to validate behavior when remote log is disabled.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| fluss-server/src/main/java/org/apache/fluss/server/log/LogTablet.java | Rolls a TTL-expired active segment under safety conditions during TTL retention; narrows roll exception type. |
| fluss-server/src/test/java/org/apache/fluss/server/log/remote/TieredLocalSegmentTTLTest.java | Expands tiered TTL coverage to include expired active-segment rolling and related retention/upload boundaries. |
| fluss-server/src/test/java/org/apache/fluss/server/log/LocalSegmentTTLTest.java | Adds regression coverage for TTL cleanup behavior when remote log is disabled. |
Suppressed comments (1)
fluss-server/src/main/java/org/apache/fluss/server/log/LogTablet.java:1383
- The PR description says rolling an expired active segment should only happen when remote log is enabled, but this condition currently depends only on segment size/TTL and high-watermark (no remote-log-enabled guard). If the intent really is remote-log-only, consider plumbing an explicit "remote log enabled" flag into LogTablet and gating this roll on it; otherwise, please align the PR description/scope with the implemented behavior.
if (activeSegment.getSizeInBytes() > 0
&& isSegmentExpired(now, activeSegment, logTtlMs)
&& getHighWatermark() >= localLogEndOffset()) {
roll(Optional.empty());
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
|
|
||
| /** Returns the contiguous prefix of inactive segments that has expired. */ | ||
| /** Returns the contiguous prefix of expired segments and rolls an expired active segment. */ |
- Document the retention finder side effect.\n- State the conditions required to roll the active segment.
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.
Purpose
Linked issue: close #3830
Local TTL cleanup currently scans only inactive log segments. When a table becomes idle after its active segment exceeds
table.log.ttl, that segment remains active and cannot be uploaded to remote storage or removed by subsequent local retention.This change rolls a non-empty expired active segment during periodic local retention once the high watermark reaches the log end offset. The rolled segment is not deleted in the same cleanup pass; it can first be uploaded and then removed by a later cleanup.
Leader/follower segment boundary alignment during timestamp-based roll is intentionally out of scope.
Brief change log
remote.log.task-interval-duration.remoteLogEndOffsetandminRetainOffsetboundaries for inactive segments.highWatermark >= logEndOffset.remoteLogEndOffsetto cover the active segment before rolling, because rolling is required before the segment can be uploaded.LogTablet.roll(Optional.empty())path and narrow its exception declaration toIOException.TieredLocalSegmentTTLTestfor partitioned and non-partitioned tables, covering:Tests
./mvnw -pl fluss-server -DskipITs -Dcheckstyle.skip -Drat.skip -Dspotless.check.skip=true -Dtest=TieredLocalSegmentTTLTest test./mvnw -pl fluss-server spotless:checkAPI and Format
No public API, RPC protocol, configuration, or storage format changes.
Documentation
No documentation changes are required.
Generative AI disclosure
Yes. OpenAI Codex was used to assist with implementation and review.