Indhumathi27 opened a new pull request, #6590:
URL: https://github.com/apache/hive/pull/6590

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: 
https://cwiki.apache.org/confluence/display/Hive/HowToContribute
     2. Ensure that you have created an issue on the Hive project JIRA: 
https://issues.apache.org/jira/projects/HIVE/summary
     3. Ensure you have added or run the appropriate tests for your PR: 
     4. If the PR is unfinished, add '[WIP]' in your PR title, e.g., 
'[WIP]HIVE-XXXXX:  Your PR title ...'.
     5. Be sure to keep the PR description updated to reflect all changes.
     6. Please write your PR title to summarize what this PR proposes.
     7. If possible, provide a concise example to reproduce the issue for a 
faster review.
   
   -->
   
   ### 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, 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?
   <!--
   If tests were added, say they were added here. Please make sure to add some 
test cases that check the changes thoroughly including negative and positive 
cases if possible.
   If it was tested in a way different from regular unit tests, please clarify 
how you tested step by step, ideally copy and paste-able, so that other 
reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why 
it was difficult to add.
   -->
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to