Skip to content

fix: ensure manifest timestamp is monotonically increasing - #5899

Open
jackye1995 wants to merge 2 commits into
lance-format:mainfrom
jackye1995:increasing-ts
Open

jackye1995 wants to merge 2 commits into
lance-format:mainfrom
jackye1995:increasing-ts

Conversation

@jackye1995

@jackye1995 jackye1995 commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor

Manifest commit timestamps currently follow the writer's wall clock, so a clock moving backward can make later versions appear older. Set each new timestamp to max(wall_clock, previous_timestamp + 1ms), using the latest predecessor after a commit conflict. First versions use wall-clock time; restore commits use the current predecessor rather than the restored version. Reject timestamp arithmetic overflow.

This supplies the commit-side behavior discussed in #9764. It does not change cleanup or retroactively establish ordering for existing history or older writers. A future-dated commit also moves the timestamp floor into the future; that trade-off remains a review question. The file-format specification is unchanged.

Rebased onto current main with regression coverage for equal/backward/forward clocks, restores, and concurrent commit retries. Local builds, tests, and clippy were omitted as requested; CI provides validation. Formatting passed.

@jackye1995
jackye1995 marked this pull request as draft February 5, 2026 22:08
@github-actions github-actions Bot added the bug Something isn't working label Feb 5, 2026
@github-actions

github-actions Bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Code Review

P1: Potential overflow in timestamp computation

In temporal.rs:50, the expression prev + MILLIS_TO_NANOS could theoretically overflow if prev is close to u128::MAX. While this is extremely unlikely in practice (timestamps are bounded to ~10^19 nanos currently), adding a saturating add or a checked add with fallback would be more defensive:

match prev_timestamp_nanos {
    Some(prev) => std::cmp::max(current_nanos, prev.saturating_add(MILLIS_TO_NANOS)),
    None => current_nanos,
}

Minor observations (non-blocking):

  1. The documentation states "at least 1 millisecond" but the code actually enforces "exactly 1 millisecond" as the minimum increment. This is fine but worth noting for precision.

  2. Consider adding an integration-style test that actually commits multiple versions in rapid succession and verifies the timestamps are monotonically increasing end-to-end.

Overall, the change is well-structured with good test coverage and clear documentation.

@codecov

codecov Bot commented Feb 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
rust/lance/src/io/commit.rs 66.66% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@majin1102

Copy link
Copy Markdown
Contributor

A little concern on this:

If a commit writes a manifest timestamp far in the future (e.g., due to a clock error setting it one year ahead), monotonic logic treats this value as the new baseline. Consequently, all subsequent manifests are forced to use timestamps at or beyond that future point, never reverting to real wall-clock time, effectively shifting the entire dataset's timeline into the future.

@github-actions github-actions Bot added the Stale label Jun 4, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution. This PR has been inactive for a while, so we're closing it to free up bandwidth. Feel free to reopen it if you still find it useful.

@github-actions github-actions Bot closed this Jun 15, 2026
@jackye1995 jackye1995 reopened this Oct 24, 2026
@github-actions github-actions Bot added A-format On-disk format: protos and format spec docs format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). labels Oct 24, 2026
@jackye1995
jackye1995 marked this pull request as ready for review October 24, 2026 05:52
@jackye1995
jackye1995 requested a review from wjones127 October 24, 2026 05:52

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@jackye1995

Copy link
Copy Markdown
Contributor Author

@wjones127 Could you review this follow-up to your suggestion in #9764 (comment)? I've reopened and rebased the original implementation onto current main.

It uses max(wall_clock, previous_timestamp + 1ms), including after a commit conflict and during restores. I'd particularly appreciate your thoughts on the future-dated-clock trade-off raised earlier. Cleanup would still need a safe boundary for existing history and older writers before relying on this ordering.

@github-actions

Copy link
Copy Markdown
Contributor

Important

Format specification vote

This PR modifies the Lance format specification, so it requires 3 binding +1 votes from PMC members (excluding the proposer), at least one of them on the latest commit, and a minimum 72-hour voting period, weekends excluded, before it can merge. Vote by approving this PR (+1) or requesting changes (−1, a veto). See the voting process.

Approvals carry over across pushes, so a rebase or a typo fix does not send everyone back to re-vote. Whoever approves the latest commit is vouching that nothing substantive has changed since the earlier approvals; if something has, ask for fresh votes.

Status: ❌ Blocked — 0 of 3 required approvals

Approvals none (0/3)
Latest commit approved by none — one PMC member must approve the latest commit
Vetoes none
Voting period ends Thu 2026-10-29 00:00 UTC (Wed 17:00 PDT)

Updated automatically by the format-spec vote gate, which re-checks every 15 minutes — just voted? Re-check now (press Run workflow; leave the input blank to re-check every open format PR). A PMC member may apply the format-waived label to waive the vote for a trivial edit (typo, wording, formatting).

@jackye1995 jackye1995 removed A-format On-disk format: protos and format spec docs Stale format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). labels Oct 24, 2026

@lance-gatekeeper lance-gatekeeper Bot 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.

🟡 Gate recommendation: maintainer decision required.

The author’s follow-up leaves the future-clock concern open. One writer a year ahead makes later commits remain future-dated after its clock is corrected, including through restores. Those commits stay outside normal asof cutoffs and time-based cleanup until wall time catches up.

Please choose whether continued writes justify that unbounded timestamp skew, or whether excessive skew should reject commits with an explicit recovery policy. Keeping wall-clock timestamps and representing ordering separately is a larger alternative.

#9764 has merged with timestamp policies still reading manifests. This change alone does not establish ordering across existing history or older writers for a cleanup shortcut.

@lance-gatekeeper lance-gatekeeper Bot added the K-decision Latest Gatekeeper review requires a maintainer decision. label Oct 24, 2026

@wjones127 wjones127 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.

@majin1102 is right that we can't mess with the timestamp without potentially distorting the timestamps via the write skew.

If we really want this optimization, I think we need a separate field that's a monotonic_timestamp high water mark, and say it's explicitly used for the "can I stop scanning here?" search. That's a format change, but not a super expensive one. Unclear if it's worth it yet, but if we see more cases where it would be beneficial worth considering.

This branch has not been deployed

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

Labels

bug Something isn't working K-decision Latest Gatekeeper review requires a maintainer decision.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants