Skip to content

fix(catalog): a dropped table keeps its location until its purge has finished - #2270

Merged
c-thiel merged 1 commit into
mainfrom
ct/purge-location-reserved
Nov 9, 2026
Merged

c-thiel merged 1 commit into
mainfrom
ct/purge-location-reserved

Conversation

@c-thiel

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

Copy link
Copy Markdown
Member

In a warehouse without soft deletion, dropping a table, view or generic table with purge (the default when the client sends no purgeRequested) removes it from the catalog at once and deletes its files later, in a purge task. With soft deletion, the same happens when the soft deletion expires. Until now the location was free as soon as the catalog entry was gone. Another table, view or generic table could take the same location, a folder inside it or a parent folder before or while the purge ran, for example by registering the dropped table's metadata file again. The purge then deleted the files of that table.

Lakekeeper now treats the location as taken while a purge task for it is queued or running. Creating a table, view or generic table, registering a table, or moving a view there fails with 409 LocationAlreadyTaken and the message "Location '…' overlaps the location of a dropped table, view or generic table whose files a purge task will delete. The location is free again when that task has finished." The location is free again when the purge task has finished, failed for good or was cancelled.

For reviewers:

  • The purge check is part of the existing location check statement. A drop deletes the row and queues the purge in one transaction, so the statement always sees one of the two.
  • The purge check leaves out no id, because register reuses the UUID of the dropped table.
  • The check reads tabular_location from the purge task payload. The new tests fail if the queue name or the payload key changes.
  • Cost: about 1 µs per pending purge task of the warehouse, on every create, register and view commit. After a drop of tens of thousands of tables, this is tens of milliseconds per create until the purges have finished.
  • A running purge that is cancelled keeps deleting until its next heartbeat (up to 60 s), while the location is already free.

Release notes

  • After a table, view or generic table is dropped with purge, its location stays taken until the purge task has finished. Before, another table could take the location, for example by registering the dropped table's metadata file again, and the purge then deleted its files. Scripts that drop a table with purge and at once create a new one at the same location, for example after Spark deleted the files itself, now get a 409 until the purge task has finished.

Downstream follow-up

  • Test helpers that drop with purge and then register the same metadata again must wait until the purge task has ended, not only until the location is empty. Otherwise the register can fail with 409 LocationAlreadyTaken.

Summary by CodeRabbit

  • Bug Fixes
    • Locations associated with tables or views awaiting purge remain unavailable, including overlapping parent or nested locations. They become reusable once purging finishes.
    • Attempts to use a location during a pending purge now report a conflict that identifies the pending purge.
  • Documentation
    • Clarified location reuse rules for dropped tables, views, and generic tables while files are being purged.

…finished

A drop with purge deletes the catalog entry at once and queues a task that deletes the files later. Until now the location was free as soon as the entry was gone. Another table, view or generic table could take the same location, a folder inside it or a parent folder before the purge ran, for example by registering the dropped table's metadata file again. The purge then deleted its files.

The location check now also matches queued or running purge tasks of the warehouse, in the same statement as the check for existing tables and views. Creating a table, view or generic table, registering a table, or moving a view to such a location fails with 409 LocationAlreadyTaken until the purge task has ended.
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Location availability checks now include queued or running purge tasks. Overlapping locations remain blocked until purge completes, with a distinct conflict response. Integration tests cover path overlaps and reuse after purge, and the documentation describes the reservation.

Changes

Pending-Purge Location Reservation

Layer / File(s) Summary
Detect pending-purge conflicts
crates/lakekeeper-storage-postgres/src/tabular/mod.rs, crates/lakekeeper/src/service/catalog_store/tabular.rs
The location check compares requested paths with tabular locations and purge-task paths. It returns a distinct error when a purge task is pending.
Verify and document location reservation
crates/lakekeeper-integration-tests/tests/drop_recursive.rs, crates/lakekeeper-storage-postgres/src/tabular/mod.rs, docs/docs/concepts.md, docs/docs/generic-tables.md
Integration tests check overlapping locations before and after purge completion. Documentation describes the location reservation behavior.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Possibly related PRs

Suggested reviewers: brgr-s

Merge Risk: Minimal · up to b2998

Dropped tables, views and generic tables now keep their location reserved until the purge finishes. This prevents a late purge from deleting files that a new catalog item has taken over. No merge-blocking risk was identified.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main behavior change: a dropped table keeps its location until its purge finishes. The raw summary and PR objectives both describe this reservation of the location while the purge…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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: Title check

Explanation

The title states the main behavior change: a dropped table keeps its location until its purge finishes. The raw summary and PR objectives both describe this reservation of the location while the purge task is queued or running, and the 409 LocationAlreadyTaken checks that enforce it. The title uses the fix(catalog) prefix and is a single, specific sentence, so it is clear to a teammate scanning history.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. 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 2 functions across 3 files. (2 skipped: 2 unsupported.)

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

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 each path with care
While purge tasks run, no table goes there
The nested folders wait their turn
Then paths are free when files are gone
Hop, the tests confirm the return!

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: dd915614-96e7-48d7-9610-475bb67ce06f
Commits

Reviewing files that changed from the base of the PR and between b012142 and b2998d4.

Files ignored due to path filters: 1

  • .sqlx/query-b2f754c566ddf105ff712ab02cdde928ebdbcaf92dfd1c2fec71667eb38c39c1.json is excluded by !.sqlx/**
Files selected for processing: 5

  • crates/lakekeeper-integration-tests/tests/drop_recursive.rs
  • crates/lakekeeper-storage-postgres/src/tabular/mod.rs
  • crates/lakekeeper/src/service/catalog_store/tabular.rs
  • docs/docs/concepts.md
  • docs/docs/generic-tables.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.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

✅ PR Title Formatted Correctly

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

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