Core: cleanExpiredMetadata cleans unreferenced encryption keys#16395
Draft
Hugo-WB wants to merge 1 commit into
Draft
Core: cleanExpiredMetadata cleans unreferenced encryption keys#16395Hugo-WB wants to merge 1 commit into
Hugo-WB wants to merge 1 commit into
Conversation
Hugo-WB
commented
May 18, 2026
| .map(EncryptedKey::keyId) | ||
| .filter(keyId -> !reachableKeyIds.contains(keyId)) | ||
| .collect(Collectors.toSet()); | ||
| encryptionKeysToRemove.forEach(updatedMetaBuilder::removeEncryptionKey); |
Contributor
Author
There was a problem hiding this comment.
In a similar line to: #12670
I see 2 arguments to introduce/make RemoveEncryptionKey -> RemoveEncryptionKeys. (Bulk).
- Performance: We've ran into performance issues server side when expiring 150k+ snapshots in a non-bulk way. Bulking the changes fixed it. Although I don't expect
RemoveEncryptionKeyto be as expensive of a call asRemoveSnapshot. So perhaps a premature optimisation. - Consistency: Consistent with the other
RemovePartitionSpecsandRemoveSchemas
Curious to hear thoughts.
| Sets.newConcurrentHashSet( | ||
| base.encryptionKeys().stream() | ||
| .map(EncryptedKey::encryptedById) | ||
| .filter(Objects::nonNull) |
Contributor
Author
There was a problem hiding this comment.
For my own understanding. Couldn't figure out why encryptedById is nullable. In what cases do we expect this to be null?
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.
Fixes part 2 of: #16352
The implementation constructs a set of "reachable"/"referenced" encryption keys-ids. Any key that is not referenced, we delete.
A key can be referenced in 2 places:
key-idfor every snapshot. This references the key that was used to encrypt the manifest list for that snapshotencrypted-by-idfor another encryption key.