hehuiyuan opened a new pull request, #20868:
URL: https://github.com/apache/hudi/pull/20868

   ### Describe the issue this Pull Request addresses
   
   As a Hudi table accumulates writes, the archived timeline under 
.hoodie/archived grows unboundedly (V1: rolled .commits_.archive.N files; V2: 
LSM parquet files + manifests) and is never reclaimed, wasting storage on 
long-running tables. This PR adds a Spark stored procedure 
delete_archive_history_file to clean expired archive history based on a 
retention policy: cutoff = requested time of the earliest commit/deltacommit 
instant in the active timeline minus a configurable retain_days (default 30).
   
   ### Summary and Changelog
   
   Adds a CALL delete_archive_history_file(table => 'tbl', retain_days => 30, 
options => '...') procedure.
   
   - V1 timeline layout (
   
[ArchiveHistoryFileCleaner.java](https://file+.sourcegraphstatic.com/main-resource-nonce?-848633479#)
   ): under the archiver's transaction lock, deletes 
.commits_.archive.<version> files whose version is strictly lower than the 
highest present AND whose mtime is strictly before the cutoff. Files are 
re-checked (size/mtime) right before deletion; the highest version is always 
retained.
   - V2 timeline layout (LSM) (
   
[LSMTimelineWriter.trimBefore()](https://file+.sourcegraphstatic.com/main-resource-nonce?-848633479#)
   ): publishes a new manifest snapshot excluding fully-expired parquet files 
and rewriting boundary files (only records >= cutoff are kept, written to a 
staged file then promoted via rename). Publication is crash-safe: no rollback, 
orphaned files are left for the regular archive cleaner.
   - Procedure registration, docs, and tests for both layouts (V1 file-level 
rules, no-commit-instant no-op case, V2 boundary retention, idempotency, 
old-snapshot visibility).
   
   ### Impact
   
   - New user-facing procedure delete_archive_history_file (new public surface, 
no breaking changes).
   - Deletion is irreversible: archived instants older than the cutoff are 
permanently removed. Run with archiving quiesced or a shared lock provider 
configured via options.
   - No storage-format change; deleted_files/archive_size_bytes are reported 
for V1.
   
   ### Risk Level
   
   medium — the procedure permanently deletes archived timeline history. 
Mitigations: highest-version retention and pre-delete re-check (V1); 
snapshot-only publication without deleting published data (V2); positive-int 
retain_days validation; tests cover expired/retained boundary, no-commit case, 
idempotency, and old-snapshot readability.
   
   ### Documentation Update
   
   <!-- Describe any necessary documentation update if there is any new 
feature, config, or user-facing change. If not, put "none".
   
   - The config description must be updated if new configs are added or the 
default value of the configs are changed.
   - Any new feature or user-facing change requires updating the Hudi website. 
Please follow the 
     [instruction](https://hudi.apache.org/contribute/developer-setup#website) 
to make changes to the website. -->
   
   ### Contributor's checklist
   
   - [ ] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [ ] Enough context is provided in the sections above
   - [ ] Adequate tests were added if applicable
   


-- 
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]

Reply via email to