Skip to content

[server] Respect the option of table.log.ttl for local segments#3222

Open
zuston wants to merge 2 commits intoapache:mainfrom
zuston:logttl
Open

[server] Respect the option of table.log.ttl for local segments#3222
zuston wants to merge 2 commits intoapache:mainfrom
zuston:logttl

Conversation

@zuston
Copy link
Copy Markdown
Member

@zuston zuston commented Apr 28, 2026

Purpose

Enable TTL-expired local log segments to be rolled (bypass the limitation of num segment retained), while preserving a new empty active segment for future appends.

This PR is to reduce the partitioned log table bucket local storage capacity, especially longterm day level partition log table

Brief change log

  • Added active-segment TTL roll logic in LogTablet.
  • Trigger active-segment TTL roll before remote tiering selects upload candidates.
  • Added coverage for rolling, uploading, local cleanup, and subsequent appends after TTL.

Tests

API and Format

Documentation

@zuston zuston changed the title [server] Respect the option of 'table.log.ttl' for local segments [server] Respect the option of table.log.ttl for local segments Apr 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Fluss server log tiering so that table.log.ttl is respected for local segments as well: when the active local segment is TTL-expired, it can be rolled to become eligible for remote tiering and subsequent local cleanup, while keeping a new empty active segment ready for future appends.

Changes:

  • Add TTL-based rolling for a non-empty active segment in LogTablet, and allow TTL-expired segments to bypass the “retain N local segments” restriction during local cleanup.
  • Trigger TTL-based active-segment rolling at the start of each LogTieringTask run so remote tiering can upload the rolled segment.
  • Extend remote log TTL tests to cover rolling/upload/cleanup behavior and appends after rolling.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
fluss-server/src/test/java/org/apache/fluss/server/log/remote/RemoteLogTTLTest.java Updates TTL expectations and adds a test covering expired active-segment roll, upload, local deletion, and subsequent appends.
fluss-server/src/main/java/org/apache/fluss/server/log/remote/LogTieringTask.java Rolls a TTL-expired active segment before selecting upload candidates.
fluss-server/src/main/java/org/apache/fluss/server/log/LogTablet.java Introduces active-segment TTL roll and TTL-aware local deletability logic (bypassing retained-segment count when expired).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1212 to +1221
int tierProtectedStartIndex = logSegments.size() - tieredLogLocalSegments;
long now = clock.milliseconds();

for (int i = 0; i < logSegments.size() - 1; i++) {
if (logSegments.get(i + 1).getBaseOffset() > endOffset) {
break;
}
if (i < tierProtectedStartIndex || isSegmentExpired(now, logSegments.get(i))) {
deletableSegments.add(logSegments.get(i));
}
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