You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix time-travel lookup to not assume snapshot-log ordering #17358
SnapshotUtil.nullableSnapshotIdAsOfTime() finds the time-travel snapshot by iterating snapshot-log and returning the last entry with timestampMillis <= requested. This implicitly assumes entries are in strictly ascending time order.
However:
The spec does not mandate ordering of snapshot-log entries
TableMetadata only validates ordering with a 1-minute clock-skew tolerance, meaning entries within that window can be in reverse order
In the reverse-order case, the loop may return the wrong snapshot — an earlier entry that happens to appear later in the list
Fix: Instead of relying on iteration order, find the entry with the maximum timestamp that is still <= requestedTimestamp.
Something like:
for (HistoryEntry logEntry : table.history()) {
if (logEntry.timestampMillis() <= timestampMillis) {
if (snapshotId == null || logEntry.timestampMillis() > bestTimestamp) {
snapshotId = logEntry.snapshotId();
bestTimestamp = logEntry.timestampMillis();
}
}
}
This makes the behavior correct regardless of entry ordering.
Willingness to contribute
I can contribute a fix for this bug independently
I would be willing to contribute a fix for this bug with guidance from the Iceberg community
I cannot contribute a fix for this bug at this time
Activity
xndai commentedon Jul 24, 2026
PR created #17360
Core: Fix time-travel snapshot lookup to not assume snapshot-log orde…
Core: Fix time-travel snapshot lookup to not assume snapshot-log orde…
rahulsmahadev commentedon Aug 6, 2026
This looks fixed by #17360, which merged on 2026-07-30.
SnapshotUtil.nullableSnapshotIdAsOfTimenow tracks the maximum qualifying timestamp instead of relying on the iteration order of the snapshot log:which is the approach suggested here, and
TestSnapshotUtil#snapshotIdAsOfTimeWithOutOfOrderHistorycovers the reverse-order case. Can this be closed?