[#11298] feat(iceberg-rest): add async cleanup manager#11299
Open
roryqi wants to merge 1 commit into
Open
Conversation
Add IcebergCleanupManager, the worker engine that pulls PENDING jobs from the iceberg_cleanup_job store, drives the cleanup state machine (claim, heartbeat, succeed, fail-after-max-attempts), deletes data files with a server-wide pool, and prunes finished rows past the retention window. Includes its unit tests, which run against the H2/MySQL/PostgreSQL backend matrix via TestJDBCBackend. Also sync the async hard-deletion design doc with the merged persistence layer: the dropTable enqueue snippet now uses the IcebergCleanupJob constructor and IcebergCleanupManager, and the testing section names TestIcebergCleanupManager. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Code Coverage Report
Files
|
yuqi1129
reviewed
May 31, 2026
| .build()); | ||
| cleanupManager.enqueue( | ||
| new IcebergCleanupJob( | ||
| 0L, // id assigned from IdGenerator at enqueue (§5.4) |
Contributor
There was a problem hiding this comment.
The flag (§5.4) is not so proper, and we can't get what it refers to
Comment on lines
+136
to
+137
| workers = Executors.newFixedThreadPool(workerThreads, daemon("iceberg-cleanup-worker")); | ||
| scheduler = Executors.newScheduledThreadPool(1, daemon("iceberg-cleanup-scheduler")); |
Contributor
There was a problem hiding this comment.
You need to declare the queue in the thread pool, or the size is unlimited.
| workers.submit(this::workerLoop); | ||
| } | ||
|
|
||
| long heartbeatIntervalMs = Math.max(1L, heartbeatTimeoutMs / 3L); |
Contributor
There was a problem hiding this comment.
heartbeatIntervalMs can be 1?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
IcebergCleanupManager: a server-wide worker pool that polls theiceberg_cleanup_jobstore forPENDINGjobs, claims them via a heartbeat lease, deletes the dropped table's reachable files in bulk through a shareddeleteExecutor(withCallerRunsPolicyback-pressure), renews heartbeats on a separate scheduler thread, drives the retry state machine (transient failure → back toPENDING, give up atmax-attempts→FAILED), and prunes finished rows past the retention window.TestIcebergCleanupManagerunit tests, running against the H2/MySQL/PostgreSQL backend matrix viaTestJDBCBackend.dropTableenqueue snippet and the testing section).Why are the changes needed?
Second of three stacked PRs for async hard deletion in the Iceberg REST catalog. The persistence layer (#11266) added the durable job store; this PR adds the worker engine that drains jobs and deletes files. REST integration follows in PR 3.
Fix: #11298
Does this PR introduce any user-facing change?
No. The manager is not yet wired into the REST drop path (that lands in PR 3), and the config keys (
async-cleanup.*) were introduced with the persistence layer (#11266).How was this patch tested?
./gradlew :iceberg:iceberg-rest-server:test --tests "org.apache.gravitino.iceberg.service.cleanup.TestIcebergCleanupManager" -PskipITs— 7 tests pass (lifecycle toSUCCEEDED, transient-retry toFAILED, bulk-delete batching, already-deleted-file tolerance, reachable-file cleanup, and tombstone delegation).