Skip to content

fix(commit): store the server clock as last-updated-ms - #2220

Merged
c-thiel merged 3 commits into
mainfrom
ct/commit-last-updated-server-clock
Nov 3, 2026
Merged

c-thiel merged 3 commits into
mainfrom
ct/commit-last-updated-server-clock

Conversation

@c-thiel

@c-thiel c-thiel commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

A client with a wrong clock can no longer make a table unwritable or unloadable for other clients. Lakekeeper now records its own clock as the table's last-updated-ms on every commit, as Iceberg Java's REST catalog does since 1.11 (apache/iceberg#14504). Before, the table took the time of the last snapshot the client added. A client whose clock ran ahead could block every other writer until the clock caught up. A snapshot from such a client on a branch, or a staged (WAP) snapshot, followed by any metadata-only commit such as a property change or snapshot expiry, stored metadata that no client could load again. Snapshot times keep the time the client sent; a rollback or publish of main is logged at Lakekeeper's clock, as in Java.

Writers whose clock is behind Lakekeeper's also commit as with Java's REST catalog: on any branch, and on main as long as their snapshots stay in order. Writers whose clock is more than one minute behind can fail to commit to main shortly after it changed; Iceberg Java clients then fail before they send the commit. Keep the clocks of all Lakekeeper instances and their clients synchronized, for example with NTP. The production checklist now says so.

A commit refused because of the times answers 400, as Java's reference server does:

  • TimestampAheadOfServerClock: a new main snapshot dated more than one minute after Lakekeeper's clock. The same applies to every other commit to a table whose stored times are more than one minute after Lakekeeper's clock, for example registered metadata from a host with a fast clock, or a Lakekeeper instance whose clock is behind another's. A commit whose snapshot is stale answers 409 first, as in Java, so the client reloads. Commits succeed again once the clock catches up.
  • TimestampBeforeTableHistory: a new main snapshot dated more than one minute before the table's snapshot log.

Bumps iceberg-rust to 5117310e4, branch lakekeeper-main-2026-11-03 of lakekeeper/iceberg-rust (on top of lakekeeper/iceberg-rust#17):

  • build-time validation in Java's order;
  • the two iceberg-rust-only snapshot time checks removed;
  • the new TableMetadataBuilder::set_last_updated_ms.

Merge after #2218.

Release notes

  • A client with a wrong clock can no longer make a table unwritable or unloadable: Lakekeeper records its own clock as the table's last-updated time, as Iceberg Java's REST catalog does since 1.11. Lakekeeper refuses a new main snapshot dated more than one minute in the future.
  • Upgrade note, clock synchronization: writers whose clock is more than one minute behind Lakekeeper's can fail to commit to a table that changed shortly before. Keep the clocks of Lakekeeper and its clients synchronized.

Downstream follow-up

Lakekeeper Plus pins iceberg directly and must move to the same iceberg-rust rev in the same step. New iceberg-rust public API: TableMetadataBuilder::set_last_updated_ms.

Summary by CodeRabbit

  • New Features
    • Table commits now use a consistent server timestamp for last-updated times. Commits are rejected when metadata is more than one minute ahead of the server clock, when a main-branch snapshot is more than one minute ahead, or when a main-branch snapshot is more than one minute behind recent table history.
  • Documentation
    • The production checklist explains clock synchronization requirements and how clock differences between Lakekeeper and query engines can affect commits.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Walkthrough

Table commits now use one shared server timestamp for last-updated-ms. Timestamp-related build failures can return specific HTTP 400 errors, while other build failures remain conflicts. Unit and integration tests cover clock skew and commit outcomes. The production checklist adds clock synchronization guidance.

Changes

Commit timestamp handling

Layer / File(s) Summary
Server clock and timestamp classification
Cargo.toml, crates/lakekeeper/src/server/commit_tables.rs, crates/lakekeeper/src/server/tables.rs
try_commit_tables passes one timestamp to each table commit. apply_commit uses it for last-updated-ms and classifies timestamp-related build failures. The iceberg dependency revision also changes.
Timestamp classification tests
crates/lakekeeper/src/server/commit_tables.rs
Tests cover timestamp tolerances, clock skew, main-branch snapshot history, and existing conflict behavior.
Integration coverage and clock guidance
crates/lakekeeper-integration-tests/tests/server_tables_postgres.rs, docs/docs/production.md
Integration tests cover shared server timestamps, clock-skew cases, rejected commits, and metadata reloadability. The production checklist describes clock synchronization and timestamp-related commit outcomes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Possibly related PRs

  • lakekeeper/lakekeeper#2218: Changes stale-snapshot error classification and pins iceberg-rust; this change updates the pin and retains the resulting conflict classification.

Suggested reviewers: jankaul

Merge Risk: Minimal · up to ebeaa

The change makes Lakekeeper record its own clock as last-updated-ms on every commit and adds clock-skew handling with matching documentation and tests. No merge-blocking issue remains from this review.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the primary change: storing the server clock as last-updated-ms during commits.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 14 functions across 3 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ast-grep (0.51.1)

ast-grep could not parse rule config: /ast-grep-rules/ast-grep-essentials/rules/html/security/malformed-erb-end-modifier-html.yml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the clock at dawn
Two tables share the time it’s drawn
Snapshots keep their given date
Skewed main commits may have to wait
Tests hop through each branch and log
Clocks in sync, the rabbit’s jog

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4dc9a76f-24e7-46a8-86d1-5a830959eb78
Commits

Reviewing files that changed from the base of the PR and between e56992b and ebeaaa4.

Files ignored due to path filters: 1
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 4
  • Cargo.toml
  • crates/lakekeeper-integration-tests/tests/server_tables_postgres.rs
  • crates/lakekeeper/src/server/commit_tables.rs
  • docs/docs/production.md
Files skipped from review as they are similar to previous changes: 1
  • docs/docs/production.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

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

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread docs/docs/production.md Resolved
Every commit now stores Lakekeeper's clock, read once per commit attempt, as the table's last-updated-ms, as Iceberg Java does since 1.11 (apache/iceberg#14504). Before, the table took the time of the last snapshot the client added. A client whose clock ran ahead could make the table unwritable for other clients, and a snapshot from such a client on a branch or a staged (WAP) snapshot, followed by any metadata-only commit, stored metadata that no client could load. Snapshot times and the snapshot-log entries of added snapshots keep the client's time; a main rollback or publish is logged at the server clock, as in Java. With the iceberg-rust fork's Java-order validation, a writer whose clock is behind Lakekeeper's commits on any branch and as the only writer on main, as with Java's REST catalog.

A build that fails because of the times answers 400, as Java's reference server does: TimestampAheadOfServerClock when the stored last-updated-ms, the last snapshot-log entry or a new main snapshot-log entry is more than one minute after the server clock, and TimestampBeforeTableHistory when a new main snapshot-log entry is more than one minute before an earlier one. Every other build error keeps 409.

The production checklist asks to keep the clocks of Lakekeeper and its clients synchronized.
@c-thiel
c-thiel force-pushed the ct/commit-last-updated-server-clock branch from e56992b to ebeaaa4 Compare November 3, 2026 07:54
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

The title of this PR match the correct format. Thank you!

@c-thiel
c-thiel enabled auto-merge (squash) November 3, 2026 08:32
@c-thiel
c-thiel merged commit 233b067 into main Nov 3, 2026
80 of 81 checks passed
@c-thiel
c-thiel deleted the ct/commit-last-updated-server-clock branch November 3, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant