You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/11/26 10:54:05 UTC

[iotdb] branch fix_error_log_to_warn created (now f493d66)

This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a change to branch fix_error_log_to_warn
in repository https://gitbox.apache.org/repos/asf/iotdb.git.


      at f493d66  catch NullPointerException and log error

This branch includes the following new commits:

     new f493d66  catch NullPointerException and log error

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 01/01: catch NullPointerException and log error

Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch fix_error_log_to_warn
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit f493d660461de61ed2d5946f34bae86e1df677bf
Author: qiaojialin <64...@qq.com>
AuthorDate: Thu Nov 26 18:53:34 2020 +0800

    catch NullPointerException and log error
---
 .../org/apache/iotdb/db/service/TSServiceImpl.java | 147 +++++++++++++++------
 1 file changed, 108 insertions(+), 39 deletions(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
index ce8e397..9145e51 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/TSServiceImpl.java
@@ -295,7 +295,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
           // release as many as resources as possible, so do not break as soon as one exception is
           // raised
           exceptions.add(e);
-          logger.error("Error in closeSession : ", e);
+          logger.warn("Error in closeSession : ", e);
         }
       }
     }
@@ -342,9 +342,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         releaseQueryResource(req.queryId);
       }
 
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("Error in closeOperation : ", e);
       return RpcUtils.getStatus(TSStatusCode.CLOSE_OPERATION_ERROR, "Error in closeOperation");
+    } catch (Exception e) {
+      logger.warn("Error in closeOperation : ", e);
+      return RpcUtils.getStatus(TSStatusCode.CLOSE_OPERATION_ERROR, "Error in closeOperation");
     }
     return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
   }
@@ -390,14 +393,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
           status = RpcUtils.getStatus(TSStatusCode.METADATA_ERROR, req.getType());
           break;
       }
-    } catch (MetadataException | OutOfMemoryError e) {
+    } catch (NullPointerException | OutOfMemoryError e) {
       logger.error(
           String.format("Failed to fetch timeseries %s's metadata", req.getColumnPath()), e);
       status = RpcUtils.getStatus(TSStatusCode.METADATA_ERROR, e.getMessage());
       resp.setStatus(status);
       return resp;
     } catch (Exception e) {
-      logger.error("Error in fetchMetadata : ", e);
+      logger.warn("Error in fetchMetadata : ", e);
       status = RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
       resp.setStatus(status);
       return resp;
@@ -440,10 +443,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       } else {
         return RpcUtils.getStatus(result);
       }
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils
           .getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
+    } catch (Exception e) {
+      logger.warn(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
+      return RpcUtils
+          .getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
     } finally {
       Measurement.INSTANCE.addOperationLatency(Operation.EXECUTE_JDBC_BATCH, t1);
     }
@@ -471,7 +478,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
           ERROR_PARSING_SQL + " " + statement + " " + e.getMessage()));
       return false;
     } catch (SQLParserException e) {
-      logger.error("Error occurred when executing {}, check metadata error: ", statement, e);
+      logger.warn("Error occurred when executing {}, check metadata error: ", statement, e);
       result.add(RpcUtils.getStatus(
           TSStatusCode.SQL_PARSE_ERROR,
           ERROR_PARSING_SQL + " " + statement + " " + e.getMessage()));
@@ -489,10 +496,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
           RpcUtils.getStatus(TSStatusCode.QUERY_NOT_ALLOWED,
               "query statement not allowed: " + statement));
       return false;
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       result.add(RpcUtils.getStatus(
           TSStatusCode.INTERNAL_SERVER_ERROR, "server Internal Error: " + e.getMessage()));
+    } catch (Exception e) {
+      logger.warn(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
+      result.add(RpcUtils.getStatus(
+          TSStatusCode.INTERNAL_SERVER_ERROR, "server Internal Error: " + e.getMessage()));
     }
     return true;
   }
@@ -520,7 +531,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       logger.warn(ERROR_PARSING_SQL, req.getStatement() + " " + e.getMessage());
       return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR, e.getMessage());
     } catch (SQLParserException e) {
-      logger.error(CHECK_METADATA_ERROR, e);
+      logger.warn(CHECK_METADATA_ERROR, e);
       return RpcUtils.getTSExecuteStatementResp(
           TSStatusCode.METADATA_ERROR, CHECK_METADATA_ERROR + e.getMessage());
     } catch (QueryProcessException e) {
@@ -528,9 +539,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return RpcUtils.getTSExecuteStatementResp(
           RpcUtils.getStatus(TSStatusCode.QUERY_PROCESS_ERROR,
               "Meet error in query process: " + e.getMessage()));
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getTSExecuteStatementResp(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
+    } catch (Exception e) {
+      logger.warn(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
+      return RpcUtils.getTSExecuteStatementResp(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
     }
   }
 
@@ -566,13 +580,17 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR,
           ERROR_PARSING_SQL + e.getMessage());
     } catch (SQLParserException e) {
-      logger.error(CHECK_METADATA_ERROR, e);
+      logger.warn(CHECK_METADATA_ERROR, e);
       return RpcUtils.getTSExecuteStatementResp(
           TSStatusCode.METADATA_ERROR, CHECK_METADATA_ERROR + e.getMessage());
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getTSExecuteStatementResp(
           RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage()));
+    } catch (Exception e) {
+      logger.warn(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
+      return RpcUtils.getTSExecuteStatementResp(
+          RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage()));
     }
   }
 
@@ -606,13 +624,17 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       return RpcUtils.getTSExecuteStatementResp(TSStatusCode.SQL_PARSE_ERROR,
           ERROR_PARSING_SQL + e.getMessage());
     } catch (SQLParserException e) {
-      logger.error(CHECK_METADATA_ERROR, e);
+      logger.warn(CHECK_METADATA_ERROR, e);
       return RpcUtils.getTSExecuteStatementResp(
           TSStatusCode.METADATA_ERROR, CHECK_METADATA_ERROR + e.getMessage());
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getTSExecuteStatementResp(
           RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage()));
+    } catch (Exception e) {
+      logger.warn(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
+      return RpcUtils.getTSExecuteStatementResp(
+          RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage()));
     }
   }
 
@@ -739,7 +761,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
 
       return resp;
     } catch (Exception e) {
-      logger.error("{}: Internal server error: ", IoTDBConstant.GLOBAL_DB_NAME, e);
+      logger.warn("{}: Internal server error: ", IoTDBConstant.GLOBAL_DB_NAME, e);
       if (e instanceof NullPointerException) {
         e.printStackTrace();
       }
@@ -747,7 +769,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         try {
           releaseQueryResource(queryId);
         } catch (StorageEngineException ex) {
-          logger.error("Error happened while releasing query resource: ", ex);
+          logger.warn("Error happened while releasing query resource: ", ex);
         }
       }
       return RpcUtils.getTSExecuteStatementResp(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
@@ -810,7 +832,7 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       case MERGE_STATUS:
         return StaticResps.MERGE_STATUS_RESP;
       default:
-        logger.error("Unsupported show content type: {}", showPlan.getShowContentType());
+        logger.warn("Unsupported show content type: {}", showPlan.getShowContentType());
         throw new QueryProcessException(
             "Unsupported show content type:" + showPlan.getShowContentType());
     }
@@ -1023,11 +1045,11 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         return resp;
       }
     } catch (Exception e) {
-      logger.error("{}: Internal server error: ", IoTDBConstant.GLOBAL_DB_NAME, e);
+      logger.warn("{}: Internal server error: ", IoTDBConstant.GLOBAL_DB_NAME, e);
       try {
         releaseQueryResource(req.queryId);
       } catch (StorageEngineException ex) {
-        logger.error("Error happened while releasing query resource: ", ex);
+        logger.warn("Error happened while releasing query resource: ", ex);
       }
       return RpcUtils.getTSFetchResultsResp(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
     }
@@ -1123,10 +1145,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       }
       String statement = req.getStatement();
       return executeUpdateStatement(statement, req.getSessionId());
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getTSExecuteStatementResp(
           RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage()));
+    } catch (Exception e) {
+      logger.warn(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
+      return RpcUtils.getTSExecuteStatementResp(
+          RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage()));
     }
   }
 
@@ -1207,10 +1233,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       if (zoneId != null) {
         resp = new TSGetTimeZoneResp(tsStatus, zoneId.toString());
       }
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("meet error while generating time zone.", e);
       tsStatus = RpcUtils.getStatus(TSStatusCode.GENERATE_TIME_ZONE_ERROR);
       resp = new TSGetTimeZoneResp(tsStatus, "Unknown time zone");
+    } catch (Exception e) {
+      logger.warn("meet error while generating time zone.", e);
+      tsStatus = RpcUtils.getStatus(TSStatusCode.GENERATE_TIME_ZONE_ERROR);
+      resp = new TSGetTimeZoneResp(tsStatus, "Unknown time zone");
     }
     return resp;
   }
@@ -1222,9 +1252,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       String timeZoneID = req.getTimeZone();
       sessionIdZoneIdMap.put(req.getSessionId(), ZoneId.of(timeZoneID));
       tsStatus = RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("meet error while setting time zone.", e);
       tsStatus = RpcUtils.getStatus(TSStatusCode.SET_TIME_ZONE_ERROR);
+    } catch (Exception e) {
+      logger.warn("meet error while setting time zone.", e);
+      tsStatus = RpcUtils.getStatus(TSStatusCode.SET_TIME_ZONE_ERROR);
     }
     return new TSStatus(tsStatus);
   }
@@ -1274,10 +1307,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
                   && isAllSuccessful);
         }
         statusList.add(status);
-      } catch (Exception e) {
+      } catch (NullPointerException e) {
         logger.error("meet error when insert in batch", e);
         isAllSuccessful = false;
         statusList.add(RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR));
+      } catch (Exception e) {
+        logger.warn("meet error when insert in batch", e);
+        isAllSuccessful = false;
+        statusList.add(RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR));
       }
     }
 
@@ -1320,10 +1357,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
                   && isAllSuccessful);
         }
         statusList.add(status);
-      } catch (Exception e) {
+      } catch (NullPointerException e) {
         logger.error("meet error when insert in batch", e);
         isAllSuccessful = false;
         statusList.add(RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR));
+      } catch (Exception e) {
+        logger.warn("meet error when insert in batch", e);
+        isAllSuccessful = false;
+        statusList.add(RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR));
       }
     }
 
@@ -1395,8 +1436,10 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         return status;
       }
       return executeNonQueryPlan(plan);
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("meet error when insert", e);
+    } catch (Exception e) {
+      logger.warn("meet error when insert", e);
     }
     return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
@@ -1425,8 +1468,10 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         return status;
       }
       return executeNonQueryPlan(plan);
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("meet error when insert", e);
+    } catch (Exception e) {
+      logger.warn("meet error when insert", e);
     }
     return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
@@ -1453,8 +1498,10 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         return new TSStatus(status);
       }
       return new TSStatus(executeNonQueryPlan(plan));
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("meet error when delete data", e);
+    } catch (Exception e) {
+      logger.warn("meet error when delete data", e);
     }
     return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
@@ -1483,10 +1530,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
       }
 
       return executeNonQueryPlan(insertTabletPlan);
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("{}: error occurs when executing statements", IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils
           .getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
+    } catch (Exception e) {
+      logger.warn("{}: error occurs when executing statements", IoTDBConstant.GLOBAL_DB_NAME, e);
+      return RpcUtils
+          .getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
     } finally {
       Measurement.INSTANCE.addOperationLatency(Operation.EXECUTE_RPC_BATCH_INSERT, t1);
     }
@@ -1529,10 +1580,12 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         return RpcUtils.getStatus(statusList);
       }
       return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS);
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("{}: error occurs when insertTablets", IoTDBConstant.GLOBAL_DB_NAME, e);
-      return RpcUtils
-          .getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
+      return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
+    } catch (Exception e) {
+      logger.warn("{}: error occurs when insertTablets", IoTDBConstant.GLOBAL_DB_NAME, e);
+      return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
     } finally {
       Measurement.INSTANCE.addOperationLatency(Operation.EXECUTE_RPC_BATCH_INSERT, t1);
     }
@@ -1552,8 +1605,10 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         return new TSStatus(status);
       }
       return new TSStatus(executeNonQueryPlan(plan));
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("meet error when set storage group", e);
+    } catch (Exception e) {
+      logger.warn("meet error when set storage group", e);
     }
     return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
@@ -1575,8 +1630,10 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         return new TSStatus(status);
       }
       return new TSStatus(executeNonQueryPlan(plan));
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("meet error when delete storage groups", e);
+    } catch (Exception e) {
+      logger.warn("meet error when delete storage groups", e);
     }
     return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
@@ -1602,8 +1659,10 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         return status;
       }
       return executeNonQueryPlan(plan);
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("meet error when create timeseries", e);
+    } catch (Exception e) {
+      logger.warn("meet error when create timeseries", e);
     }
     return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
@@ -1712,8 +1771,10 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         logger.debug("Create multiple timeseries failed!");
         return RpcUtils.getStatus(statusList);
       }
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("meet error when create multi timeseries", e);
+    } catch (Exception e) {
+      logger.warn("meet error when create multi timeseries", e);
     }
     return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
@@ -1735,8 +1796,10 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
         return status;
       }
       return executeNonQueryPlan(plan);
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error("meet error when delete timeseries", e);
+    } catch (Exception e) {
+      logger.warn("meet error when delete timeseries", e);
     }
     return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR);
   }
@@ -1758,11 +1821,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
             "No permissions for this operation " + plan.getOperatorType().toString());
       }
     } catch (AuthException e) {
-      logger.error("meet error while checking authorization.", e);
+      logger.warn("meet error while checking authorization.", e);
       return RpcUtils.getStatus(TSStatusCode.UNINITIALIZED_AUTH_ERROR, e.getMessage());
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
+    } catch (Exception e) {
+      logger.warn(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
+      return RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
     }
     return null;
   }
@@ -1775,11 +1841,14 @@ public class TSServiceImpl implements TSIService.Iface, ServerContext {
     } catch (BatchInsertionException e) {
       return RpcUtils.getStatus(Arrays.asList(e.getFailingStatus()));
     } catch (QueryProcessException e) {
-      logger.error("meet error while processing non-query. ", e);
+      logger.warn("meet error while processing non-query. ", e);
       return RpcUtils.getStatus(e.getErrorCode(), e.getMessage());
-    } catch (Exception e) {
+    } catch (NullPointerException e) {
       logger.error(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
       return RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
+    } catch (Exception e) {
+      logger.warn(SERVER_INTERNAL_ERROR, IoTDBConstant.GLOBAL_DB_NAME, e);
+      return RpcUtils.getStatus(TSStatusCode.INTERNAL_SERVER_ERROR, e.getMessage());
     }
 
     return execRet