[core] Fix that latestSnapshotOfUser might list snapshot directory to find the earliest#7572
Merged
JingsongLi merged 1 commit intoapache:masterfrom Apr 1, 2026
Merged
Conversation
… find the earliest
Contributor
|
+1 |
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
Previously, latestSnapshotOfUser called earliestSnapshotId() to determine the loop bound before iterating snapshots.
During checkpoint, if the snapshot pointed to by the EARLIEST hint is concurrently expired, the hint misses and earliestSnapshotId() falls back to findByListFiles(), which lists the entire snapshot directory.
This method is called during every checkpoint via prepareCommit → createWriterCleanChecker → latestCommittedIdentifier → latestSnapshotOfUserFromFilesystem. For jobs with high parallelism and a large number of snapshots (e.g. 10000+), this might cause massive listStatus requests, easily triggering QPS limits on object storage (e.g. OSS QpsLimitExceeded).
The fix removes the earliestSnapshotId() call and instead iterates backward from the latest snapshot, stopping when a FileNotFoundException is encountered (indicating an expired snapshot). Other exceptions are thrown directly.
Tests
testLatestSnapshotOfUser can test the loop can break.