HIVE-29818: ServletSecurity needs a UGI cache - #6704
Open
henrib wants to merge 1 commit into
Open
Conversation
The REST Catalog creates a fresh proxy UserGroupInformation per request via UserGroupInformation.createProxyUser. Hadoop's FileSystem.CACHE retains a reference to every such UGI (and its RPC/IPC resources), so under proxy authentication these short-lived UGIs accumulate and eventually exhaust memory in long-running deployments. Cache the proxy UGI in ServletSecurity with a bounded, idle-evicting Caffeine cache keyed by (realUser, loginUser). Evicted entries release their resources via FileSystem.closeAllForUGI. Two new config vars tune the cache: - metastore.catalog.servlet.ugi.cache.size (default 1000) - metastore.catalog.servlet.ugi.cache.expiry (default 3600s, 0 disables) Add TestServletSecurity covering per-user caching, distinct proxies per user, eviction-triggered FileSystem cleanup, and disabled expiry.
Copilot stopped reviewing on behalf of
henrib due to an error
August 17, 2026 15:39
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?
The REST Catalog creates a fresh proxy
UserGroupInformationper request viaUserGroupInformation.createProxyUser. Hadoop'sFileSystem.CACHEretains a reference to every such UGI (and its RPC/IPC resources), so under proxy authentication these short-lived UGIs accumulate and eventually exhaust memory in long-running deployments.This PR caches the proxy UGI in
ServletSecurityusing a bounded, idle-evicting Caffeine cache keyed by(realUser, loginUser). Evicted entries release their resources viaFileSystem.closeAllForUGI. Two new config vars tune the cache:metastore.catalog.servlet.ugi.cache.size(default 1000)metastore.catalog.servlet.ugi.cache.expiry(default 3600s, 0 disables expiry)A note in the code documents why eviction-while-in-use is not reference-counted: eviction is idle-based (
expireAfterAccess) and both the expiry window and max size are expected to be kept well above the longest operation / peak concurrent distinct users.Why are the changes needed?
To prevent the
OutOfMemoryErrorcaused by unbounded accumulation of proxy UGIs and their associated FileSystem/IPC resources in long-running REST Catalog deployments.Does this PR introduce any user-facing change?
Two new (optional) metastore configuration properties, both with sensible defaults.
How was this patch tested?
Added
TestServletSecuritycovering per-user caching, distinct proxies per user, eviction-triggeredFileSystem.closeAllForUGIcleanup, and disabled expiry. All 4 tests pass.