Skip to content

docs(format): specify history retention rule for cleanup - #10924

Open
wjones127 wants to merge 7 commits into
lance-format:mainfrom
wjones127:will/history-retention-spec
Open

wjones127 wants to merge 7 commits into
lance-format:mainfrom
wjones127:will/history-retention-spec

Conversation

@wjones127

@wjones127 wjones127 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Cleanup reads tags and branches once and then deletes. A tag, branch, or restore published during that window can reference a version cleanup is deleting (#10499). This specifies a per-branch retention rule that cleanup writes before deleting anything:

tree/{branch}/_retention/7.json   {"expiredBefore": 106, "retained": [102, 105]}
_refs/pins/{uuid}.json            {"branch": null, "version": 98, "createdAt": "..."}
  • Versions below expiredBefore and not in retained are expired. They stay readable; expiration only blocks new references.
  • Rules are written as {n+1}.json with put-if-not-exists, and each new rule merges with the current one, so expiration never goes backwards. An explicit override may lift it for repairs.
  • Tag create/update and branch create write the ref, then read the rule, and roll back if the version is expired.
  • Restore writes a pin, checks the rule, commits, and deletes the pin. Cleanup treats pins like tags.

The rule lives in side files rather than the manifest so cleanup still makes no commits. Writers that don't implement this ignore the files, and a missing or malformed rule expires nothing, so old clients keep today's behavior. Retention leases (#10428) are unaffected.

Design discussion: #10499 (comment). The implementation follows in a separate PR. This supersedes #10504.

Merge Risk

Door: one-way. It reserves _retention/ and _refs/pins/ and defines their contents.
Blast Radius: format, concurrency (cleanup, tags, branches, restore).

Refs #10499

🤖 Generated with Claude Code

@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). documentation Improvements or additions to documentation labels Nov 10, 2026
Comment thread docs/src/format/table/branch_tag.md Resolved
@wjones127
wjones127 marked this pull request as ready for review November 10, 2026 23:09

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

@github-actions

github-actions Bot commented Nov 10, 2026 •

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 elapsed — ended Fri 2026-11-13 23:09 UTC (15:09 PST)

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).

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Nov 10, 2026

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

Pending GK finding resolution.

@lance-gatekeeper lance-gatekeeper Bot added K-changes Latest Gatekeeper recommendation requests changes. and removed K-changes Latest Gatekeeper recommendation requests changes. labels Nov 11, 2026
Config keys made every deleting cleanup commit a version. Store the rule
in per-branch _retention/{n}.json files written with put-if-not-exists,
make expiration monotonic, and pin restore targets while restoring.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wjones127
wjones127 force-pushed the will/history-retention-spec branch from 897462a to 66bc665 Compare November 11, 2026 19:18
@wjones127 wjones127 changed the title docs(format): specify history retention keys for cleanup docs(format): specify history retention rule for cleanup Nov 11, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Nov 11, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Nov 11, 2026
@lance-gatekeeper lance-gatekeeper Bot added K-changes Latest Gatekeeper recommendation requests changes. and removed K-changes Latest Gatekeeper recommendation requests changes. labels Nov 11, 2026
@wjones127

Copy link
Copy Markdown
Contributor Author

A smaller alternative is the manifest-based design, with the corrected expiration union and restore validation on every commit attempt. That couples expiration to restore conflicts, at the cost of a table version when the rule changes. If keeping side files, preserve durable generation fencing and continuous protection until cleanup can observe the committed restored snapshot, including after a publisher pauses.

The reason I changed was that I found the version writes were unacceptable. At first I thought it was just one commit, but then I realized it was O(num branches) commits. On top of that, each time we run cleanup, we create new versions that might need to be cleaned up, so a branch that receives no writes continuously gets new cleanup operations committing to it. Hence why I wanted to go to a design that doesn't commit a manifest.

@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Nov 11, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-changes Latest Gatekeeper recommendation requests changes. and removed K-changes Latest Gatekeeper recommendation requests changes. labels Nov 11, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Nov 11, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Nov 11, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Nov 11, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 11, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 11, 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: approve.

The tightened specification preserves monotonic expiration and continuous restore protection under its single-cleanup precondition and 24-hour restore commit deadline.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 11, 2026
@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 13, 2026

@Xuanwo Xuanwo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please clarify how an existing table can adopt the per-branch _retention/ layout. v14.0.3 permits nested branch names that occupy the proposed rule directory. Reserving the name for new branches, as #10964 proposes, still leaves tables that already use that path.

An isolated namespace would avoid the overlap. If the specification keeps this layout, please define how a writer detects the conflict before enabling retention writes and how an upgrade preserves both the existing branch and the retention rules.

For the rollout in #10964, please include write-triggered automatic cleanup alongside manual cleanup and expire_versions when documenting the requirement that only one cleanup run at a time.

@lichuang

Copy link
Copy Markdown
Contributor

Use case for pins: strict expected-head commits (#8699 / #11021)

#11021 adds a commit mode that must fail unless the dataset head is exactly the transaction's read_version at publication. Review there found that a conditional write to the target manifest slot is not a sufficient fence: cleanup can free the slot mid-publication, and a post-publish head check cannot distinguish "my write lost" from "a successor built on my write".

This spec's pin + retention-rule mechanism looks like exactly the fence needed, with one new usage: pinning a target version that has no manifest yet.

Protocol for a strict commit targeting version T = expected + 1:

  1. Preflight: latest version is expected.
  2. Write a pin for T.
  3. Read the branch's current rule; if T is expired, remove the pin and fail.
  4. Build and conditionally write the manifest at T (put-if-not-exists).
  5. Remove the pin; report the outcome.

Correctness follows the same "whichever goes second sees the other" argument as restore: a cleanup that deletes the contents of slot T without seeing my pin must have written its rule before my pin, and since expiration is monotonic my step-3 read observes T expired and fails; a cleanup that lists pins after my pin keeps T, so my conditional write fails honestly if another writer occupies the slot. Conditional-put success then uniquely means I won slot T while the head was expected — no post-publish head read is needed, and a successor committing T+1 on top of my manifest is simply a later commit, not a lost race.

Two spec clarifications would make this usage well-defined:

  1. May a pin reference a version whose manifest does not exist yet? (Restore always pins an existing version.)
  2. Is cleanup's "keep every version they reference" keyed purely on the version number, regardless of when the manifest appears during the run? feat: write history retention rule before cleanup deletes #10964's pinned_versions already behaves this way, so this would just be spelling it out.

If this direction sounds right, I'm happy to send a small spec addition to "Publishing References" covering expected-head commits, and rebase #11021 onto #10964 once it lands.

One open question for this usage: pins go stale after 24 hours, which implicitly bounds how long a strict commit may hold its fence. For commit-time work that can exceed that (e.g. a long compaction build before publication), would you rather have the writer refresh the pin, or treat >24h strict commits as out of scope?

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. and removed K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 29, 2026

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

A-format On-disk format: protos and format spec docs documentation Improvements or additions to documentation format-change A change to the format spec, which requires a vote. Remove if minor (e.g. fixing typo). K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants