HIVE-29708: HMS Memory leak: Ensure FileSystem.closeAllForUGI is invoked on proxy user failure#6590
Open
Indhumathi27 wants to merge 1 commit into
Open
HIVE-29708: HMS Memory leak: Ensure FileSystem.closeAllForUGI is invoked on proxy user failure#6590Indhumathi27 wants to merge 1 commit into
Indhumathi27 wants to merge 1 commit into
Conversation
magnuma3
approved these changes
Jul 9, 2026
Contributor
|
@Indhumathi27 , The same fix can be applied on hive/ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/MRCompactor.java Lines 127 to 140 in be59bd0 |
…ked on proxy user failure
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?
This patch fixes a FileSystem.CACHE leak in TxnUtils.findUserToRunAs().
When the Hive Metastore service user cannot access a table location, findUserToRunAs() creates a proxy user and attempts to access the path using the proxy user's FileSystem. If this access check throws an exception (for example, due to insufficient HDFS permissions), the cached FileSystem instance associated with the proxy user is never released because FileSystem.closeAllForUGI() is not invoked.
This patch ensures that FileSystem.closeAllForUGI(ugi) is always executed by moving the cleanup into a finally block, preventing leaked DistributedFileSystem instances regardless of whether the access check succeeds or fails.
A similar code path exists in the compactor Worker & MRCompactor, where proxy FileSystem instances could also be left cached on exception. This patch applies the same cleanup there as well to ensure consistent resource handling across both the Initiator and Worker.
Why are the changes needed?
When the proxy user access check fails, the cached DistributedFileSystem remains referenced by the static FileSystem.CACHE. During repeated compactor initiator scans, these cached instances accumulate, leading to increasing heap usage and eventually an OutOfMemoryError in the Hive Metastore.
Ensuring cleanup on all execution paths prevents the cache leak while preserving the existing behavior of determining the appropriate user to run compactions.
Does this PR introduce any user-facing change?
No
How was this patch tested?
Manually tested. Unit test cases also added