Repository navigation
feat(format): specify retention leases - #10428
brendanclement wants to merge 18 commits into
Conversation
2ebb935 to
52fca11
Compare
|
Important Format specification voteThis 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 — 2 of 3 required approvals
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 |
westonpace
left a comment
There was a problem hiding this comment.
Haven't finished. Some initial questions
| A version-1 history is called **tagged**. If it also contains legacy versions, | ||
| it is called **mixed**. |
There was a problem hiding this comment.
Are we trying to move away from the "tagged" terminology (in preference of "version 1")? I don't actually know. But yeah, Claude seems to like "tagged" (maybe we have a bunch of comments referring to it?)
There was a problem hiding this comment.
I switched the prose to FRI version 1 and spelled out when a version 1 history contains legacy records. I think the agents like "tagged" because of comments and it kindof stuck.
| @@ -202,6 +205,30 @@ trimmed. Cleanup must retain intermediate transitions still needed to translate | |||
| old addresses. External mapping files can be deleted only when no retained | |||
| dataset version references them. | |||
There was a problem hiding this comment.
Can we fold this paragraph into the new section and just title it Cleanup?
There was a problem hiding this comment.
Combined these into one Cleanup section so the existing-index and in-progress-job requirements are explained together
| that union at the final commit target of every operation that trims or replaces | ||
| history, including work planned before registration. Restore and Overwrite | ||
| apply this check to the resulting current history; they may discard translation | ||
| paths while preserving current pins and their source snapshots. |
There was a problem hiding this comment.
This is very LLM-ish. It reads like a dump of dense facts. Can we provide a bit of motivation first?
Something like...
An FRI can be removed (cleaned up) once all artifacts referencing the source fragments have been removed. For example, an index that maps search results to fragments A and B will prevent an FRI from getting cleaned up when A and B are source fragments in the FRI. This is because the FRI is still needed to map the results of index searches.
Sometimes we also want to keep an FRI alive even when there are no artifacts referencing source fragments because those artifacts are currently being created by an in-progress task. For example, if an index is being trained against fragments A and B, this process may take several hours. We do not want the an FRI that maps A or B to be cleaned up while this training takes place.
To solve this problem we utilize ongoing-work pins...
There was a problem hiding this comment.
Ok i changed this so cleanup now starts with the example of an index pointing at A/B after compaction moves the rows to C, then explains why an index still being built needs the same history.
| a monotonically increasing version number, and an optional reference to the index section that describes a list of index metadata. | ||
|
|
||
| [Ongoing work pins](ongoing_work_pins.md) record unfinished jobs' source snapshots | ||
| and FRI retention requirements in the current manifest. See that specification |
There was a problem hiding this comment.
Can we prefer "in-progress" over "unfinished"? When I see the latter term I think "failed" or "abandoned"
There was a problem hiding this comment.
Changed to in-progress.
|
|
||
| [Ongoing work pins](ongoing_work_pins.md) record unfinished jobs' source snapshots | ||
| and FRI retention requirements in the current manifest. See that specification | ||
| for their lifecycle and the existing maintenance concurrency limits. |
There was a problem hiding this comment.
What does "existing maintenance concurrency limits" mean?
There was a problem hiding this comment.
This meant that checking for pins and physically deleting a branch are separate steps. A deletion could check an empty pin list, then continue after a job registers a pin. I decided that this vague phrase from this overview just leads to more questions and instead I added that example to the limitations section.
| inclusive source-version boundary. Tagged and mixed histories retain records | ||
| reachable from pinned source fragments, including all downstream dependencies |
There was a problem hiding this comment.
How is "pinned source fragments" determined? Do we read the pin's version and load all fragments at that version?
There was a problem hiding this comment.
Yes, we load and validate the manifest at the pin's source version and use all fragment IDs listed there. That just reads metadata. For FRI version 1, we follow the movement records forward from those IDs. I've made this more explicit in both sections.
| /* UUID of the source manifest's committing transaction. | ||
| * Absent or empty is invalid; compare exact UTF-8 bytes. | ||
| */ | ||
| optional string source_transaction_uuid = 1; |
There was a problem hiding this comment.
So originally this was to distinguish snapshots in a case where the table is deleted and recreated at the same path, but the agent went all-out in trying to red-team and break this implementation. I've removed this from the schema because i think it's overkill.
| @@ -0,0 +1,275 @@ | |||
| # Ongoing Work Pins | |||
|
|
|||
| An ongoing-work pin adds a retention requirement for a fixed source snapshot | |||
There was a problem hiding this comment.
| An ongoing-work pin adds a retention requirement for a fixed source snapshot | |
| An ongoing-work pin adds a retention requirement for a fixed source version |
I find LLMs like to use snapshot (likely due to the prevalence of Iceberg) but the proper term should be "version" or "manifest" to match the rest of the spec.
There was a problem hiding this comment.
I’ve changed the pin documentation to use version for the table state and manifest for the metadata describing it.
| This feature does not add atomic coordination between protection acquisition, | ||
| restore, and destructive maintenance. Existing tags also use separate | ||
| acquisition and retention checks. A tag created after cleanup's inspection can | ||
| succeed while that sweep still deletes its old source files. An earlier sweep | ||
| can likewise delete files adopted by a concurrent restore, and a delayed branch | ||
| deletion can damage a replacement after overlapping recovery and name reuse. | ||
|
|
||
| Current-version-only acquisition avoids selecting an arbitrary old version | ||
| already eligible for cleanup. A sweep retains the head it inspected, and the | ||
| usual grace period protects newly written, unverified files while they remain | ||
| recent. This narrows exposure compared with old-version tags, but is not a | ||
| general concurrency guarantee: the grace period can elapse or be bypassed by | ||
| `delete_unverified`, and restore can reintroduce older files. The old-version | ||
| tag case is not evidence that every current-version pin has the same exposure. | ||
|
|
||
| The pin checks do not cancel an earlier deletion plan or prevent a destructive | ||
| operation from running after confirmation. A successful registration therefore | ||
| does not guarantee safety against these overlapping operations. Callers must | ||
| not treat the pin as a lock against destructive maintenance. | ||
|
|
||
| These are existing maintenance and branch-coordination gaps. Their fixes are | ||
| outside this proposal; no deletion marker, permanent name retirement, new | ||
| branch layout, or reference journal is specified. Branch names remain reusable. | ||
| This limitation does not relax the required active-pin checks, the retention | ||
| of sources selected by those checks, or the transactional FRI retention rules. |
There was a problem hiding this comment.
This entire paragraph is difficult to parse. I think what we are trying to say here is that a race condition potentially exists between acquiring a pin and running cleanup. We can both succeed in acquiring a pin and still clean up the version if the two operations were running at the same time?
Is there any advice on mitigation? It seems we should generally be ok as long as the cleanup interval is long enough right? For example, if the cleanup interval is one hour then as long as we pin at the start of a long-running operation then we're probably safe right?
There was a problem hiding this comment.
yeah so registration can succeed before an earlier deletion finishes, though I think this paragraph made it sound broader than it actually is. pins only register against the current version, and cleanup retains the current version it inspected.
one case where this can happen is a restore. cleanup selects some old files for deletion, then a user restores a version that references those files and a job pins that restored version. cleanup can still delete those files based on its earlier check. adding the pin doesn't cancel that decision. so running cleanup once an hour wouldn't guarantee we're safe here either, because the restore could still happen while cleanup is running.
| incompatible operations already in flight. Existing branch deleters that never | ||
| inspect capability flags are not made safe by this bit. | ||
|
|
||
| ## Maintenance concurrency limits |
There was a problem hiding this comment.
Calling these "maintenance concurrency limits" is a little confusing. We aren't really talking about limiting concurrency here are we?
There was a problem hiding this comment.
I’ve renamed it to Cleanup and deletion races and updated the links.
Revert drive-by edits to unrelated feature flags and FRI wording, restore the external mapping file rule, and renumber RetentionLease fields. Align no-op and expiry rules across files, drop the "attached" qualifier, and shorten the lease section in transaction.md. A decoded manifest that lists leases now always carries writer bit 20, so this build refuses writes that would drop the list. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Release by the planned publication UUID keeps publication and lease removal in one commit. Listed leases now block this implementation’s writers even when bit 20 is omitted; lease support remains disabled.
The accepted complete-version retention accumulates intermediate data and index generations. The idle-table expiration concern remains: expired leases retain resources until another commit or explicit release. Restore, overwrite, and branch deletion end protection and can interrupt holders. Publication still requires normal conflict validation and transaction evidence; lease absence alone does not establish success.
This can land as a specification while bit 20 remains unsupported. Activation requires complete version/transaction retention and commit-time FRI checks across lease-aware writers and maintenance clients. Applications coordinating restore and cleanup can drain cleanup before restore and pause it through acquisition; a flag cannot stop deletion already in flight. The runtime history protection reverted by #10440 cannot supply these guarantees.
…nder leases Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Implementation plan for retention leases, stacked on this PR:
API decisions:
|
…n stable-row-ID tables Co-Authored-By: Claude Opus 5.5 <[email protected]>
westonpace
left a comment
There was a problem hiding this comment.
Looks great, just some minor nits
| {1, 2} -> {5} keep: an index references fragment 1 | ||
| {4} -> {6} keep: the leased version contains fragment 4 | ||
| {6} -> {7} keep: translating fragment 4 to 7 passes through 6 | ||
| {8} -> {9} trim: no index or retention lease references fragment 8 |
There was a problem hiding this comment.
Can you show an example where the target frag (but not the source) intersects with an index/lease? In this case I think you can trim correct?
For example, compaction combines 8 and 9 into 10 and then a new index is created on a new column (and so it covers frag 10) but nothing else needs 8 or 9 anymore.
| It contains the complete schema definition including nested fields, the list of data fragments comprising this version, | ||
| a monotonically increasing version number, and an optional reference to the index section that describes a list of index metadata. | ||
|
|
||
| [Retention leases](retention_leases.md) retain a leased version, the versions |
There was a problem hiding this comment.
This seems like a slightly odd place to put this concept. Maybe put it way down after overlay files or potentially even as a related specification?
It'll be an implementation detail for all but the most hardcore of readers
| and cleanup must retain the transactions of versions after F. If cleanup cannot | ||
| confirm that a required version or transaction is present, it **must not | ||
| delete** files that version might need. |
There was a problem hiding this comment.
What does this last sentence mean? Why would cleanup not be able to confirm a required version or transaction is present?
| confirm that a required version or transaction is present, it **must not | ||
| delete** files that version might need. | ||
|
|
||
| Acquisition does not cancel deletions that cleanup approved before it. |
There was a problem hiding this comment.
Maybe we can add "to avoid job failure the lease should be applied well before any configured retention interval so that lease acquisition does not race with cleanup operations"
There was a problem hiding this comment.
Honestly, I think I can just remove this sentence entirely. Because we atomically create the lease and the version it's on, cleanup should never race. This sentence is really about versions before F, which aren't really relevant.
There was a problem hiding this comment.
Cleanup isn't a transaction though so I think it can still race. We could avoid it with some kind of "mark for death" operation (which is incredibly tempting now that I've thought of that name) but we don't have that.
0:00 - Cleanup begins, starts scanning versions to see which ones are still too old
0:30 - Cleanup decides versions 5, 6, and 7 can be deleted and starts scanning to find appropriate files
0:45 - User decides to create an index using version 7 as the read version and commits a retention lease (oops too late)
1:00 - Cleanup deletes version 7 and all its files
There was a problem hiding this comment.
#10924
I actually am considering implementing a "mark for death" in this other proposal.
There was a problem hiding this comment.
The design here is that a user can't commit a retention lease for a version that exists. They request a lease, and they get back a new version number. Because cleanup never deletes the latest version, a lease can never refer to something that's already being cleaned up.
So your sequence corrected:
0:00 - Cleanup begins, starts scanning versions to see which ones are still too old
0:30 - Cleanup decides versions 5, 6, and 7 can be deleted and starts scanning to find appropriate files
0:45 - User decides to create an index. Requests a retention lease, gets back new version 9 as the read version to use and commits a retention lease (oops too late)
1:00 - Cleanup deletes version 7 and all its files
There was a problem hiding this comment.
Oh wait, now I see your point (here and in the other question). The user wouldn't use version 7 as the read version. They would have to use the newly created version 8 and version 8 would already be protected 🤔 Clever!
There was a problem hiding this comment.
Yes, this whole sentence can be removed then.
| | Rewrite | If the rewrite replaces fragments a listed lease requires, it must record FRI transitions for them; otherwise it conflicts and must be replanned. | | ||
| | Restore, Overwrite | Remove all leases. Existing data conflicts remain. | | ||
| | Clone | Start the destination with no leases and no lease flag. | | ||
| | AcquireLease | Return a listed ID without changing it. Otherwise, add the lease against the new head with an unexpired request. | |
There was a problem hiding this comment.
Minor nit: can we rephrase so the typical case is first?
Add the lease against the new head with an unexpired request if the ID is not listed. Otherwise return it without changing it.
Clarify why leases are listed while expired, why the holder is handed its version, and when cleanup cannot confirm lease history; drop the acquisition/cleanup race note; add a destination-only FRI trim example; move the lease summary to related specifications. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Transaction V2 took field 116 for CompositeOperation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Not trying to block but, and sorry for being late but, did we consider something like matching FRI retention to the existing dataset retention period, so leases are only needed for builds that outlive normal GC or need stronger guarantees?
I tested a 48h FRI window locally, and index builds committed across multiple compactions while the old versions were retained. For ordered compaction on 100M rows, mapping files stay small like ~40KiB (meaning a week of hourly history might roughly be ~270 KiB, compared to ~16.4 GiB for the dataset directory). So storage shouldnt be a problem.
Since the builds only fail once cleanup deletes the old manifests and data files, matching the FRI and dataset retention seems like it would cover the common case.
I'm mostly wondering if we need to add some additional complexity in the commit protocol and another feature flag, especially with everything we're already adding to the transaction layer. Is there a reason the existing retention mechanisms wouldn't be enough?
That's a good question. And I would like that solution if GC was still based off of a time based threshold. Unfortunately, there's been recent changes in GC scheduling that make it not just a pure time cut off. Now there's mechanisms that are based off of how many versions to keep and there's mechanisms that do thinning based on hourly or daily time windows. Because of this, we can't guarantee that cleanup will only delete things after us a certain period—it might also delete things sooner than long running jobs complete and so I think that does make this necessary. |
|
ahh I see... I think I'm used to a world where retention policies use both a minimum number of versions and a time window, so both conditions need to be met before cleanup. maybe we could support something similar here, where we keep every version within a minimum window before "thinning" or version based cleanup kicks in? file retention or gc could still handle file reachability from the retained manifests, and we'd keep FRI mappings for that same window, or longer if committed indexes still need them. compaction would also need to record those mappings even when no committed index exists, but that would let builds finishing within the window commit without having to track each one. I know longer builds wouldn't have that guarantee, and keeping all those intermediate data files could get expensive. Is that the main reason for leases, or do we have workloads that actually need stronger guarantees than a retention window provides? |
Compaction should be able to run while long-running jobs, such as async index builds, are in progress. The Fragment Reuse Index (FRI) records how compaction moves rows so those jobs can translate their results, but cleanup and FRI trimming need to know which versions and transitions the jobs still depend on.
This PR specifies retention leases. A lease is listed in the current manifest and keeps the leased version, every version after it through the head, and the FRI transitions connecting its fragments to the current layout. Leases are temporary: they expire unless renewed.
Design discussion: #10395.
Format changes:
Manifest.retention_leases(field 27) holdsRetentionLeaserecords:id,version,created_at,expires_at, andlabel.FLAG_RETENTION_LEASES) is set exactly when the lease list is nonempty, so writers without lease support reject the table only while leases exist.AcquireLease,RenewLease, andReleaseLease. Acquisition creates a new version, which becomes the leased version, and is idempotent by lease ID.This PR contains the specification, protobuf definitions, and the minimum Rust changes needed to compile. Bit 20 stays unsupported and the lease operations decode to
Operation::Unknownuntil the implementation lands in follow-up PRs. The Rust cleanup path rejects bit 20 starting withv14.0.0-beta.4.Since the earlier revision of this proposal, "ongoing work pins" were renamed to retention leases,
Transaction.release_pin_idwas replaced by release-by-UUID, and the branch identity and branch deletion rules were removed.🤖 Generated with Claude Code