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

Ferdinand Xu commented on HIVE-11579:
-------------------------------------

This will cause the operation handlers leakage in the OperationManager side. 
The general process is as follows:
{noformat}
HiveStatement#close -> HiveStatement#closeClientOperation -> 
ThriftCLIService#closeOperation 
-> CLIService#closeOperation -> HiveSessionImpl#closeOperation -> 
HiveCommandOperation#close 
->  HiveCommandOperation#teardownIO
{noformat}
And you can see the how IO is initialized in Operation:
{noformat}
  private void setupSessionIO(SessionState sessionState) {
    try {
      LOG.info("Putting temp output to file " + 
sessionState.getTmpOutputFile().toString());
      sessionState.in = null; // hive server's session input stream is not used
      // open a per-session file in auto-flush mode for writing temp results
      sessionState.out = new PrintStream(new 
FileOutputStream(sessionState.getTmpOutputFile()), true, "UTF-8");
      // TODO: for hadoop jobs, progress is printed out to session.err,
      // we should find a way to feed back job progress to client
      sessionState.err = new PrintStream(System.err, true, "UTF-8");
    } catch (IOException e) {
      LOG.error("Error in creating temp output file ", e);
      try {
        sessionState.in = null;
        sessionState.out = new PrintStream(System.out, true, "UTF-8");
        sessionState.err = new PrintStream(System.err, true, "UTF-8");
      } catch (UnsupportedEncodingException ee) {
        LOG.error("Error creating PrintStream", e);
        ee.printStackTrace();
        sessionState.out = null;
        sessionState.err = null;
      }
    }
  }
{noformat}

And how it closed:

{noformat}
  private void tearDownSessionIO() {
    IOUtils.cleanup(LOG, parentSession.getSessionState().out);
    IOUtils.cleanup(LOG, parentSession.getSessionState().err);
  }
{noformat}
Another way we can get rid of is to add a tmp err file like tmp output file 
instead of using the system.err file descriptor in the session level. But it 
will cause no error printed in the server side.

> Invoke the set command will close standard error output[beeline-cli]
> --------------------------------------------------------------------
>
>                 Key: HIVE-11579
>                 URL: https://issues.apache.org/jira/browse/HIVE-11579
>             Project: Hive
>          Issue Type: Sub-task
>          Components: CLI
>            Reporter: Ferdinand Xu
>            Assignee: Ferdinand Xu
>         Attachments: HIVE-11579-beeline-cli.patch
>
>
> We can easily reproduce the debug by the following steps:
> {code}
> hive> set system:xx=yy;
> hive> lss;
> hive> 
> {code}
> The error output disappeared since the err outputstream is closed when 
> closing the Hive statement.
> This bug occurred also in the upstream when using the embeded mode as the new 
> CLI uses.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to