Skip to content

fix(partition-ttl): Fix the integer overflow issue when TTL exceeded 24 days.#19075

Open
wangxianghu wants to merge 1 commit into
apache:masterfrom
wangxianghu:ttl_bug
Open

fix(partition-ttl): Fix the integer overflow issue when TTL exceeded 24 days.#19075
wangxianghu wants to merge 1 commit into
apache:masterfrom
wangxianghu:ttl_bug

Conversation

@wangxianghu

@wangxianghu wangxianghu commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Describe the issue this Pull Request addresses

when days to retain is bigger than 24, then writeConfig.getPartitionTTLStrategyDaysRetain() * 1000 * 3600 * 24 > Integer.MAX_VALUE, ttlInMilis <= 0 will always be true

org.apache.hudi.table.action.ttl.strategy.KeepByTimeStrategy#getExpiredPartitionPaths always return empty list.

    if (!lastCompletedInstant.isPresent() || ttlInMilis <= 0
        || !hoodieTable.getMetaClient().getTableConfig().getPartitionFields().isPresent()) {
      return Collections.emptyList();
    }

cast writeConfig.getPartitionTTLStrategyDaysRetain() to long can fix it

this.ttlInMilis = (long) writeConfig.getPartitionTTLStrategyDaysRetain() * 1000 * 3600 * 24;

Summary and Changelog

Fix daysReatain> 24 integer overflow issue

Impact

None

Risk Level

low

Documentation Update

None

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

@wangxianghu wangxianghu requested a review from stream2000 June 26, 2026 08:10
@github-actions github-actions Bot added the size:XS PR with lines of changes in <= 10 label Jun 26, 2026
@voonhous voonhous added the type:bug Bug reports and fixes label Jun 26, 2026

@hudi-agent hudi-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ 🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for the contribution! This PR fixes an integer overflow in KeepByTimeStrategy where daysRetain > 24 caused ttlInMilis to go negative, making getExpiredPartitionPaths always return an empty list. The (long) cast correctly promotes the multiplication to long arithmetic, and the added test covers the overflow boundary well. No correctness issues found. A few style/readability suggestions in the inline comments. Please take a look, and this should be ready for a Hudi committer or PMC member to take it from here. One simplification suggestion for the production-side fix — the test coverage is solid.

cc @yihua

@wangxianghu wangxianghu force-pushed the ttl_bug branch 2 times, most recently from a4c900c to 435fb50 Compare June 27, 2026 02:45
@hudi-bot

Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

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

Labels

size:XS PR with lines of changes in <= 10 type:bug Bug reports and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants