Skip to content

feat(admin-api): add table prune command#1934

Open
Theodus wants to merge 3 commits intomainfrom
theodus/table-prune
Open

feat(admin-api): add table prune command#1934
Theodus wants to merge 3 commits intomainfrom
theodus/table-prune

Conversation

@Theodus
Copy link
Member

@Theodus Theodus commented Mar 6, 2026

Schedule non-canonical segments for garbage collection instead of immediate deletion, providing a configurable safety window before files are removed.

  • Add DELETE /revisions/{id}/prune endpoint with before_block and gc_delay_secs query parameters
  • Implement canonical chain computation to identify non-canonical segments
  • Schedule files via gc_manifest table for deferred deletion by collector
  • Add ampctl table prune CLI
  • Require writer job to be terminal before pruning (same safety as truncate)

@Theodus Theodus requested review from LNSD and shiyasmohd March 6, 2026 21:26
@Theodus Theodus changed the title feat(admin-api): add table prune command with GC scheduling feat(admin-api): add table prune command Mar 6, 2026
Copy link
Contributor

@shiyasmohd shiyasmohd left a comment

Choose a reason for hiding this comment

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

Added some suggestions as comments, Major blockers are

  • Confirm revision is inactive before pruning
  • Add integration tests in it_admin_api_revisions.rs

Theodus added 2 commits March 9, 2026 07:29
Schedule non-canonical segments for garbage collection instead of immediate
deletion, providing a configurable safety window before files are removed.
- Add `DELETE /revisions/{id}/prune` endpoint with `before_block` and
  `gc_delay_secs` query parameters
- Implement canonical chain computation to identify non-canonical segments
- Schedule files via `gc_manifest` table for deferred deletion by collector
- Add `ampctl table prune` CLI with human-readable `--gc-delay` duration
- Require writer job to be terminal before pruning (same safety as truncate)
@Theodus Theodus force-pushed the theodus/table-prune branch from 7f37ac0 to 648ac5c Compare March 9, 2026 13:49
@Theodus Theodus requested a review from shiyasmohd March 9, 2026 13:54
Copy link
Contributor

@shiyasmohd shiyasmohd left a comment

Choose a reason for hiding this comment

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

I would also add a test case where there are non canonical segments.
test case would look like

  • mine 10 blocks
  • deploy with end block 10
  • reorg 3 block and mine blocks
  • deploy with end block 13
    and check files_scheduled > 0

Copy link
Contributor

@LNSD LNSD left a comment

Choose a reason for hiding this comment

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

Please, check my comments 🙂

gc_duration,
)
.await
.map_err(Error::ScheduleGc)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should centralize the GC APIs in the DataStore. For example, add a "mark for deletion" method.

Adding metadata DB manipulation functions in the Admin API handlers is a design flaw that we need to address.

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.

3 participants