Skip to content

[ISSUE-4339][Bug] Fix latest savepoint lookup#4362

Open
hutiefang76 wants to merge 2 commits into
apache:devfrom
hutiefang76:codex/streampark-4339-savepoint-latest
Open

[ISSUE-4339][Bug] Fix latest savepoint lookup#4362
hutiefang76 wants to merge 2 commits into
apache:devfrom
hutiefang76:codex/streampark-4339-savepoint-latest

Conversation

@hutiefang76

Copy link
Copy Markdown

What changes were proposed in this pull request

This PR fixes FlinkSavepointServiceImpl#getLatest when duplicate latest = true savepoint records exist for the same application.

The previous query used one(), so MyBatis-Plus called selectOne() and threw TooManyResultsException if historical data contained more than one latest savepoint. This can make checkpoint polling repeatedly log errors, as reported in #4339.

The query now orders by triggerTime and id descending and limits the result to one row, so it returns the newest latest savepoint deterministically.

Brief change log

  • Order latest savepoint lookup by triggerTime and id descending.
  • Limit the lookup to one row before calling one().
  • Add a regression test for duplicate latest = true savepoint records.

Verifying this change

  • Red test before the fix: FlinkSavepointServiceTest#testGetLatestReturnsNewestSavepointWhenDuplicateLatestRecordsExist failed with TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2.
  • After the fix: JAVA_HOME=$(/usr/libexec/java_home -v 17) ./mvnw -pl streampark-console/streampark-console-service -am -Dtest=FlinkSavepointServiceTest -Dsurefire.failIfNoSpecifiedTests=false test
  • Result: Tests run: 4, Failures: 0, Errors: 0, Skipped: 0.

Closes #4339.

wolfboys
wolfboys previously approved these changes Jun 21, 2026

@wolfboys wolfboys left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud

Copy link
Copy Markdown

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Expected one result (or null) to be returned by selectOne()

2 participants