huyuanfeng2018 opened a new issue, #6272: URL: https://github.com/apache/paimon/issues/6272
### Search before asking - [x] I searched in the [issues](https://github.com/apache/paimon/issues) and found nothing similar. ### Paimon version master ### Compute Engine all ### Minimal reproduce step ## Summary When a branch is created based on a tag, deleting that tag can cause the branch's base snapshot to be expired during snapshot expiration operations, making the branch unqueryable. Currently, Paimon has a protection mechanism that prevents snapshots referenced by tags from being expired (implemented in `ExpireSnapshotsImpl.java`). However, there's no corresponding protection for branches that reference tags. The issue occurs in the following scenario: 1. Create a tag pointing to a specific snapshot 2. Create a branch based on this tag 3. Delete the tag 4. Run snapshot expiration 5. The base snapshot of the branch gets expired because it's no longer protected by the tag 6. The branch becomes unqueryable ### What doesn't meet your expectations? base snapshot not be deleted ### Anything else? ## Proposed Solutions ### Solution 1: Tag Deletion Protection (Preferred) Add a protection mechanism when deleting tags to prevent deletion if any branches reference the tag. **Implementation approach**: - Modify `TagManager.deleteTag()` method - Before deleting a tag, check if any branches reference this tag - If branches exist, either: - Reject the deletion with an error message - Require a force flag to proceed with deletion **Advantages**: - Prevents the problem at the source - Clear error message to users - Maintains data integrity ### Solution 2: Branch-aware Snapshot Expiration Modify the snapshot expiration logic to consider branches when determining which snapshots to protect. **Implementation approach**: - Modify `ExpireSnapshotsImpl.expireUntil()` method - Add branch manager to collect all branch base snapshots - Include branch-referenced snapshots in the skipping set **Advantages**: - More comprehensive protection - Handles edge cases where branches might reference snapshots directly ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- 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]
