You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Mike Drob (JIRA)" <ji...@apache.org> on 2018/03/07 03:22:00 UTC

[jira] [Commented] (HIVE-18890) Lower Logging for "Table not found" Error

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

Mike Drob commented on HIVE-18890:
----------------------------------

Ha, you've been listening to my rants! Yes, catch-log-and-throw is generally an anti-pattern, for those unfamiliar there's a short blog post at https://rolf-engelhard.de/2013/04/logging-anti-patterns-part-ii/ that covers this and others.

Looking at this particular code snippet, the log should likely be outside of the if, before the {{return null}}, and the thrown HiveException at the end doesn't need to repeat the exception's message.

> Lower Logging for "Table not found" Error
> -----------------------------------------
>
>                 Key: HIVE-18890
>                 URL: https://issues.apache.org/jira/browse/HIVE-18890
>             Project: Hive
>          Issue Type: Improvement
>          Components: HiveServer2
>    Affects Versions: 3.0.0
>            Reporter: BELUGA BEHR
>            Priority: Minor
>
> https://github.com/apache/hive/blob/7cb31c03052b815665b3231f2e513b9e65d3ff8c/ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java#L1105
> {code:java}
>     // Get the table from metastore
>     org.apache.hadoop.hive.metastore.api.Table tTable = null;
>     try {
>       tTable = getMSC().getTable(dbName, tableName);
>     } catch (NoSuchObjectException e) {
>       if (throwException) {
>         LOG.error("Table " + tableName + " not found: " + e.getMessage());
>         throw new InvalidTableException(tableName);
>       }
>       return null;
>     } catch (Exception e) {
>       throw new HiveException("Unable to fetch table " + tableName + ". " + e.getMessage(), e);
>     }
> {code}
> We should throw an exception or log it, but not both. Right [~mdrob] ? ;)
> And in this case, we are generating scary ERROR level logging in the HiveServer2 logs needlessly.  This should not be reported as an application error.  It is a simple user error, indicated by catching the _NoSuchObjectException_ Throwable, that can always be ignored by the service.  It is most likely a simple user typo of the table name.  However, the more serious general _Exception_ is not logged.  This is backwards.
> Please remove the _error_ level logging for the user error... or lower it to _debug_ level logging.
> Please include an _error_ level logging to the general Exception case, unless this Exception is being captured up the stack, somewhere else, and is being logged there at ERROR level logging.
> {code}
> -- Sample log messages found in HS2 logs
> 2018-03-02 10:26:40,363  ERROR hive.ql.metadata.Hive: [HiveServer2-Handler-Pool: Thread-4467]: Table default not found: default.default table not found
> 2018-03-02 10:26:40,367  ERROR hive.ql.metadata.Hive: [HiveServer2-Handler-Pool: Thread-4467]: Table default not found: default.default table not found
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)