Caideyipi commented on code in PR #12313: URL: https://github.com/apache/iotdb/pull/12313#discussion_r1562381629
########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/exception/LoadFailedException.java: ########## @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.iotdb.db.exception; + +import org.apache.iotdb.commons.exception.IoTDBException; +import org.apache.iotdb.db.queryengine.plan.planner.plan.node.load.LoadSingleTsFileNode; +import org.apache.iotdb.rpc.TSStatusCode; + +import java.util.List; + +public class LoadFailedException extends IoTDBException { + + public LoadFailedException(List<LoadSingleTsFileNode> failedNodes) { + super(buildErrorMessage(failedNodes), TSStatusCode.LOAD_FILE_ERROR.getStatusCode()); + } + + private static String buildErrorMessage(List<LoadSingleTsFileNode> failedNodes) { + final StringBuilder fileNames = new StringBuilder(); + final int failedNodeSize = failedNodes.size(); + for (LoadSingleTsFileNode node : failedNodes) { + fileNames.append(node.getTsFile().getName()).append(", "); + } + + if (fileNames.length() > 0) { + fileNames.setLength(fileNames.length() - 2); + } + + return "Failed to load " + failedNodeSize + " files: " + fileNames; Review Comment: Use String.join() here may be more graceful. ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/LoadTsfileAnalyzer.java: ########## @@ -170,25 +171,27 @@ public Analysis analyzeFileByFile() { "Load - Analysis Stage: {}/{} tsfiles have been analyzed, progress: {}%", i + 1, tsfileNum, String.format("%.3f", (i + 1) * 100.00 / tsfileNum)); } + + schemaAutoCreatorAndVerifier.flush(); } catch (IllegalArgumentException e) { LOGGER.warn( "Parse file {} to resource error, this TsFile maybe empty.", tsFile.getPath(), e); - throw new SemanticException( - String.format("TsFile %s is empty or incomplete.", tsFile.getPath())); + loadTsFileStatement.addFailedTsFile(tsFile); } catch (AuthException e) { return createFailAnalysisForAuthException(e); } catch (Exception e) { LOGGER.warn("Parse file {} to resource error.", tsFile.getPath(), e); - throw new SemanticException( - String.format( - "Parse file %s to resource error, because %s", tsFile.getPath(), e.getMessage())); + loadTsFileStatement.addFailedTsFile(tsFile); } } - try { - schemaAutoCreatorAndVerifier.flush(); - } catch (AuthException e) { - return createFailAnalysisForAuthException(e); + LOGGER.info( Review Comment: "warn" maybe better? ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/plan/node/load/LoadTsFileNode.java: ########## @@ -103,6 +103,11 @@ public List<WritePlanNode> splitByPartition(Analysis analysis) { statement.isDeleteAfterLoad(), statement.getWritePointCount(i))); } + + for (int i = 0; i < statement.getFailedTsFiles().size(); i++) { + res.add( + new LoadSingleTsFileNode(getPlanNodeId(), statement.getFailedTsFiles().get(i), false)); Review Comment: I think stream maybe better :-) ########## iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/scheduler/load/LoadTsFileScheduler.java: ########## @@ -189,23 +194,30 @@ public void start() { i + 1, tsFileNodeListSize); } else { - isLoadSuccess = false; + failedTsFileNodes.add(node); LOGGER.warn( "Can not Load TsFile {}, load process [{}/{}]", node.getTsFileResource().getTsFilePath(), i + 1, tsFileNodeListSize); } } catch (Exception e) { - isLoadSuccess = false; - stateMachine.transitionToFailed(e); + failedTsFileNodes.add(node); LOGGER.warn( "LoadTsFileScheduler loads TsFile {} error", node.getTsFileResource().getTsFilePath(), e); } } - if (isLoadSuccess) { + + if (!failedTsFileNodes.isEmpty()) { + LOGGER.warn("Load - Dispatch Stage: {} TsFiles failed to load.", failedTsFileNodes.size()); + for (LoadSingleTsFileNode node : failedTsFileNodes) { + LOGGER.warn( Review Comment: Maybe the List<nodes> can be displayed directly? -- 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]
