[ 
https://issues.apache.org/jira/browse/HIVE-4503?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13778474#comment-13778474
 ] 

Zhichun Wu commented on HIVE-4503:
----------------------------------

HIVE-4500 explicitly close history file and other resources in hiveserver2's 
close session methods, but hiveserver still depends on GC to release history 
file and SessionState's tmpOutputFile. There is a clean method in ThriftHive 
interface introduced in HIVE-818 and we can use it to explicitly close a 
session in hiveserver. We can also try to clean up old resource each time we 
initize a HiveServerHandler in HiveServer.java:

{code}
@@ -134,10 +136,23 @@ public HiveServerHandler(HiveConf conf) throws 
MetaException {
|        isHiveQuery = false;
|        driver = null;
|        SessionState session = new SessionState(conf);
| +
| +      if (SessionState.get() != null) {
| +        SessionState oldSession = SessionState.get();
| +        tearDownSessionIO(oldSession);
| +      }
|        SessionState.start(session);
|        setupSessionIO(session);
|      }
|
| +    private void tearDownSessionIO(SessionState session) {
| +      HiveHistory hiveHist = session.getHiveHistory();
| +      if (null != hiveHist) {
| +        hiveHist.closeStream();
| +      }
| +      IOUtils.cleanup(LOG, session.out);
| +    }
| +
{code}
Please correct me if I miss something.

                
> HiveServer have  too  many opened  fd。 
> ---------------------------------------
>
>                 Key: HIVE-4503
>                 URL: https://issues.apache.org/jira/browse/HIVE-4503
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 0.8.1
>         Environment: Hive: hive-0.8.1 
> OS: Red Hat Enterprise Linux Server release 5.7 (Tikanga)
> Hadoop: 0.20.205
>            Reporter: sutao bian
>
> When i run hiveserver a while time it will occur error  >>> Caused by: 
> java.io.FileNotFoundException: 
> /opt/tmp/mapred/local/jobTracker/job_201301251143_76286.xml (Too many open 
> files)
> more errors info : 
> 013-05-06 02:54:47,426 WARN  parse.SemanticAnalyzer 
> (SemanticAnalyzer.java:genBodyPlan(5821)) - Common Gby keys:null
> 2013-05-06 02:54:50,386 WARN  mapred.JobClient 
> (JobClient.java:copyAndConfigureFiles(659)) - Use GenericOptionsParser for 
> parsing the arguments. Applications should implement Tool for the same.
> 2013-05-06 02:54:52,565 ERROR exec.Task (SessionState.java:printError(380)) - 
> Job Submission failed with exception 
> 'org.apache.hadoop.ipc.RemoteException(java.io.IOException: 
> java.io.FileNotFoundException: 
> /opt/tmp/mapred/local/jobTracker/job_201301251143_76286.xml (Too many open 
> files)
>       at org.apache.hadoop.mapred.JobTracker.submitJob(JobTracker.java:3943)
>       at sun.reflect.GeneratedMethodAccessor1278.invoke(Unknown Source)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:601)
>       at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:563)
>       at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1388)
>       at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1384)
>       at java.security.AccessController.doPrivileged(Native Method)
>       at javax.security.auth.Subject.doAs(Subject.java:415)
>       at 
> org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1059)
>       at org.apache.hadoop.ipc.Server$Handler.run(Server.java:1382)
> Caused by: java.io.FileNotFoundException: 
> /opt/tmp/mapred/local/jobTracker/job_201301251143_76286.xml (Too many open 
> files)
>       at java.io.FileOutputStream.open(Native Method)
>       at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
>       at 
> org.apache.hadoop.fs.RawLocalFileSystem$LocalFSFileOutputStream.<init>(RawLocalFileSystem.java:188)
>       at 
> org.apache.hadoop.fs.RawLocalFileSystem$LocalFSFileOutputStream.<init>(RawLocalFileSystem.java:184)
>       at 
> org.apache.hadoop.fs.RawLocalFileSystem.create(RawLocalFileSystem.java:242)
>       at 
> org.apache.hadoop.fs.ChecksumFileSystem$ChecksumFSOutputSummer.<init>(ChecksumFileSystem.java:335)
>       at 
> org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:368)
>       at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:546)
>       at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:527)
>       at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:434)
>       at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:229)
>       at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:163)
>       at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1164)
>       at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1145)
>       at org.apache.hadoop.mapred.JobInProgress.<init>(JobInProgress.java:415)
>       at org.apache.hadoop.mapred.JobTracker.submitJob(JobTracker.java:3941)
>       ... 10 more
> )'
> when i restart the hiveserver it will be ok .
> Thanks 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to