JingsongLi commented on code in PR #9437:
URL: https://github.com/apache/paimon/pull/9437#discussion_r3878852125


##########
paimon-core/src/main/java/org/apache/paimon/utils/SnapshotManager.java:
##########
@@ -415,8 +415,8 @@ public long repairEarliestSnapshot(long snapshotId) {
             } else if (commitTime < timestampMills) {
                 earliest = mid + 1; // Search in the right half
             } else {
-                finalSnapshot = snapshot; // Found the exact match
-                break;
+                finalSnapshot = snapshot;
+                latest = mid - 1;

Review Comment:
   [P2] Refresh the lower bound before searching past an exact match
   
   `earliest` can become stale when expiration runs between 
`earliestSnapshotId()` and the binary search. With snapshots 0/1/2 sharing this 
timestamp, expiration can delete snapshot 0 after the ID is read; the search 
first hits snapshot 1, then this new continuation probes snapshot 0 and fails 
even though snapshot 1 is the earliest surviving match. The old `break` 
returned snapshot 1.
   
   Please obtain the lower bound through `earliestSnapshot(latest)`, which 
already retries concurrent earliest deletion, return it directly when it 
satisfies the query, and cover this race in the test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to