[core] Prevent tag deletion when referenced by branches#6896
Open
userzhy wants to merge 3 commits intoapache:masterfrom
Open
[core] Prevent tag deletion when referenced by branches#6896userzhy wants to merge 3 commits intoapache:masterfrom
userzhy wants to merge 3 commits intoapache:masterfrom
Conversation
c932b6e to
27d834c
Compare
This closes apache#6272. When a branch is created from a tag, the tag's snapshot information is copied to the branch directory. However, deleting the tag could cause the snapshot expiration process to clean up data files that are still needed by the branch, making the branch unqueryable. This change adds a check in deleteTag() to verify if any branches were created from the tag before allowing deletion. If branches reference the tag, the deletion is blocked with an error message listing the referencing branches. Changes: - Added branchesCreatedFromTag() method to BranchManager interface with default empty implementation for backward compatibility - Implemented branchesCreatedFromTag() in FileSystemBranchManager to check each branch's tag directory for the specified tag - Added validation in AbstractFileStoreTable.deleteTag() to prevent deletion of tags that are still referenced by branches - Added testDeleteTagReferencedByBranch() test case to verify the fix
…n LocalOrphanFilesCleanTest
a033ee1 to
a67b459
Compare
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.
Purpose
Linked issue: close #6272
When a branch is created from a tag, the tag's snapshot information is copied to the branch directory. However, if the tag is deleted, the snapshot expiration process may clean up data files that are still needed by the branch, making the branch unqueryable.
This change implements Tag Deletion Protection: before deleting a tag, we check if any branches were created from that tag. If so, the deletion is blocked with an error message listing the referencing branches.
Changes:
branchesCreatedFromTag(String tagName)method toBranchManagerinterface with default empty implementation for backward compatibilitybranchesCreatedFromTag()inFileSystemBranchManagerto check each branch's tag directory for the specified tagAbstractFileStoreTable.deleteTag()to prevent deletion of tags that are still referenced by branchesTests
testDeleteTagReferencedByBranch()inSimpleTableTestBaseto verify:IllegalStateExceptionAPI and Format
branchesCreatedFromTag(String tagName)toBranchManagerinterface with default implementation returning empty list, so existing implementations remain compatibleDocumentation
This is a bug fix, no new feature documentation needed.