markhoerth commented on code in PR #11152: URL: https://github.com/apache/gravitino/pull/11152#discussion_r3271616245
########## design-docs/async-iceberg-rest-hard-deletion.md: ########## @@ -0,0 +1,421 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +# Design: Pluggable Asynchronous Hard Deletion for the Gravitino Iceberg REST Server + +| Field | Value | +| -------- | ------------------------------------------------------- | +| Status | Draft | +| Authors | @roryqi | +| Created | 2026-05-19 | +| Module | `iceberg/iceberg-rest-server`, `iceberg/iceberg-common` | + +--- + +## 1. Background + +When a client issues: + +``` +DELETE /v1/{prefix}/namespaces/{namespace}/tables/{table}?purgeRequested=true +``` + +today's path is fully synchronous: `IcebergTableOperations.dropTable` → +`IcebergTableOperationExecutor.dropTable` → `IcebergCatalogWrapper.purgeTable` +→ `CatalogHandlers.purgeTable`, which walks every snapshot / manifest / +data file and deletes each one through `FileIO` on the Jetty request +thread. + +For production tables this fails in three ways: + +- Multi-minute purges exceed HTTP timeouts. +- Concurrent purges saturate the Jetty pool. +- Mid-purge failures leak files with no retry or audit trail. + +We want to return quickly, finish deletion reliably in the background, +survive restarts, and let operators plug in alternative strategies +(object-store batch APIs, external job systems, audit-only) without +modifying Gravitino. + +*Not in scope:* `RelationalGarbageCollector`, which deletes tombstoned +**rows** from Gravitino's relational backend. Different IO surface, +different failure model — kept separate. + +## 2. Goals + +1. `DELETE … ?purgeRequested=true` returns at typical request latency + (target p99 < 500 ms) regardless of table size, when an async purger + is configured. +2. File-deletion strategy is **pluggable** behind an `IcebergPurger` SPI. +3. The default async implementation deletes every file the synchronous + purge would have deleted, retries transient failures, and survives + restarts. +4. No change to the Iceberg REST wire protocol. +5. Authorization runs on the **request thread**, never deferred. + +## 3. Non-Goals + +- Changing Gravitino-native soft-delete semantics. +- User-initiated cancellation of in-flight purges (v1). +- Async `dropNamespace` / `dropView` (they don't delete data today). + +## 4. Overview + +``` + IcebergPurger (SPI) + ▲ + ┌────────────────────────┼────────────────────────────┐ + │ │ │ +SynchronousIceberg- JdbcAsyncIceberg- (third-party plugins: + Purger Purger Kafka, S3 Batch, +(legacy parity) (default async) audit-only, …) +``` + +`IcebergTableOperationExecutor.dropTable` no longer knows how purge is +implemented — it calls `purger.purgeTable(request)` and the configured +plugin decides whether the work is synchronous, queued in a DB, +dispatched externally, or skipped. + +The default plugin (`JdbcAsyncIcebergPurger`) persists a job row, returns +immediately, and drains the queue from a background worker pool. + +## 5. The `IcebergPurger` SPI Review Comment: What's driving the SPI design? The PRD doesn't ask for one, and §14.4 (waiting for a third-party plugin in production before stabilizing the interface) suggests we don't have one in flight. §13 argues the SPI is "strictly more general for the same core complexity," but I'd push back on that. The SPI surface, the discovery factory, the classpath loading path, and the IcebergPurgerContext are real added complexity compared to shipping one implementation. The PRD's competitive frame against Polaris is "simpler design with smaller bug surface," and the SPI moves the wrong direction. Could we ship one default async purger in V1, keep the synchronous path as a feature flag for rollback, and revisit the SPI when a second implementation has a real customer behind it? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
