Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public void onComplete(TSStatus tsStatus) {
LOGGER.info("Successfully {} on DataNode: {}", requestType, formattedTargetLocation);
} else if (tsStatus.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) {
dataNodeLocationMap.remove(requestId);
LOGGER.error(
LOGGER.warn(
"Failed to {} on DataNode {}, {}", requestType, formattedTargetLocation, tsStatus);
} else {
LOGGER.error(
LOGGER.warn(
"Failed to {} on DataNode {}, {}", requestType, formattedTargetLocation, tsStatus);
}
countDownLatch.countDown();
Expand All @@ -73,7 +73,7 @@ public void onError(Exception e) {
+ targetDataNode.getInternalEndPoint()
+ "}"
+ e.getMessage();
LOGGER.error(errorMsg);
LOGGER.warn(errorMsg);

countDownLatch.countDown();
responseMap.put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
import org.apache.iotdb.confignode.rpc.thrift.TDeleteTimeSeriesReq;
import org.apache.iotdb.confignode.rpc.thrift.TMigrateRegionReq;
import org.apache.iotdb.confignode.rpc.thrift.TRegionMigrateResultReportReq;
import org.apache.iotdb.db.exception.BatchProcessException;
import org.apache.iotdb.db.metadata.template.Template;
import org.apache.iotdb.rpc.RpcUtils;
import org.apache.iotdb.rpc.TSStatusCode;
Expand All @@ -100,6 +101,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -906,7 +908,14 @@ private boolean waitingProcedureFinished(List<Long> procedureIds, List<TSStatus>
} else {
if (finishedProcedure.getException().getCause() instanceof IoTDBException) {
IoTDBException e = (IoTDBException) finishedProcedure.getException().getCause();
statusList.add(RpcUtils.getStatus(e.getErrorCode(), e.getMessage()));
if (e instanceof BatchProcessException) {
statusList.add(
RpcUtils.getStatus(
Arrays.stream(((BatchProcessException) e).getFailingStatus())
.collect(Collectors.toList())));
} else {
statusList.add(RpcUtils.getStatus(e.getErrorCode(), e.getMessage()));
}
} else {
statusList.add(
StatusUtils.EXECUTE_STATEMENT_ERROR.setMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
import org.apache.iotdb.commons.exception.IoTDBException;
import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.path.PathDeserializeUtil;
Expand All @@ -39,6 +40,7 @@
import org.apache.iotdb.confignode.procedure.impl.statemachine.StateMachineProcedure;
import org.apache.iotdb.confignode.procedure.state.schema.AlterLogicalViewState;
import org.apache.iotdb.confignode.procedure.store.ProcedureType;
import org.apache.iotdb.db.exception.BatchProcessException;
import org.apache.iotdb.db.exception.metadata.view.ViewNotExistException;
import org.apache.iotdb.mpp.rpc.thrift.TAlterViewReq;
import org.apache.iotdb.mpp.rpc.thrift.TInvalidateMatchedSchemaCacheReq;
Expand Down Expand Up @@ -167,14 +169,17 @@ private void alterLogicalView(ConfigNodeProcedureEnv env) throws ProcedureExcept
ViewExpression.serialize(viewEntry.getValue(), stream);
}
} catch (IOException e) {
throw new RuntimeException(e);
// won't reach here
}
viewMapBinaryList.add(ByteBuffer.wrap(stream.toByteArray()));
}
req.setViewBinaryList(viewMapBinaryList);
return req;
});
regionTaskExecutor.execute();
if (isFailed()) {
return;
}

invalidateCache(env);
}
Expand Down Expand Up @@ -241,12 +246,11 @@ private void generatePathPatternTree() {
try {
patternTree.serialize(dataOutputStream);
} catch (IOException ignored) {

// won't reach here
}
ByteBuffer patternTreeBytes = ByteBuffer.wrap(byteArrayOutputStream.toByteArray());

this.pathPatternTree = patternTree;
this.patternTreeBytes = patternTreeBytes;
this.patternTreeBytes = ByteBuffer.wrap(byteArrayOutputStream.toByteArray());
}

@Override
Expand Down Expand Up @@ -298,6 +302,8 @@ private class AlterLogicalViewRegionTaskExecutor<Q>

private final String taskName;

private final List<TSStatus> failureStatusList = new ArrayList<>();

AlterLogicalViewRegionTaskExecutor(
String taskName,
ConfigNodeProcedureEnv env,
Expand All @@ -319,10 +325,17 @@ protected List<TConsensusGroupId> processResponseOfOneDataNode(
}

if (response.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) {
List<TSStatus> subStatus = response.getSubStatus();
for (int i = 0; i < subStatus.size(); i++) {
if (subStatus.get(i).getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
failedRegionList.add(consensusGroupIdList.get(i));
List<TSStatus> subStatusList = response.getSubStatus();
TSStatus subStatus;
for (int i = 0; i < subStatusList.size(); i++) {
subStatus = subStatusList.get(i);
if (subStatus.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
if (subStatus.getCode() == TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode()) {
failedRegionList.add(consensusGroupIdList.get(i));
} else {
collectFailure(subStatus);
interruptTask();
}
}
}
} else {
Expand All @@ -331,6 +344,24 @@ protected List<TConsensusGroupId> processResponseOfOneDataNode(
return failedRegionList;
}

private void collectFailure(TSStatus failureStatus) {
if (failureStatus.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) {
failureStatusList.addAll(failureStatus.getSubStatus());
} else {
failureStatusList.add(failureStatus);
}
if (failureStatusList.size() == 1) {
setFailure(
new ProcedureException(
new IoTDBException(
failureStatusList.get(0).getMessage(), failureStatusList.get(0).getCode())));
} else {
setFailure(
new ProcedureException(
new BatchProcessException(failureStatusList.toArray(new TSStatus[0]))));
}
}

@Override
protected void onAllReplicasetFailure(
TConsensusGroupId consensusGroupId, Set<TDataNodeLocation> dataNodeLocationSet) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ public TSStatus visitAlterLogicalView(AlterLogicalViewNode node, ISchemaRegion s
schemaRegion.alterLogicalView(
SchemaRegionWritePlanFactory.getAlterLogicalViewPlan(entry.getKey(), entry.getValue()));
} catch (MetadataException e) {
logger.error("{}: MetaData error: ", IoTDBConstant.GLOBAL_DB_NAME, e);
logger.warn("{}: MetaData error: ", IoTDBConstant.GLOBAL_DB_NAME, e);
failingStatus.add(RpcUtils.getStatus(e.getErrorCode(), e.getMessage()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
import org.apache.iotdb.db.client.DataNodeClientPoolFactory;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.engine.StorageEngine;
import org.apache.iotdb.db.exception.BatchProcessException;
import org.apache.iotdb.db.exception.StorageEngineException;
import org.apache.iotdb.db.exception.metadata.PathNotExistException;
import org.apache.iotdb.db.exception.sql.SemanticException;
Expand Down Expand Up @@ -1837,7 +1838,12 @@ public SettableFuture<ConfigTaskResult> alterLogicalView(
"Failed to execute alter view {}, status is {}.",
alterLogicalViewStatement.getTargetPathList(),
tsStatus);
future.setException(new IoTDBException(tsStatus.getMessage(), tsStatus.getCode()));
if (tsStatus.getCode() == TSStatusCode.MULTIPLE_ERROR.getStatusCode()) {
future.setException(
new BatchProcessException(tsStatus.subStatus.toArray(new TSStatus[0])));
} else {
future.setException(new IoTDBException(tsStatus.getMessage(), tsStatus.getCode()));
}
} else {
future.set(new ConfigTaskResult(TSStatusCode.SUCCESS_STATUS));
}
Expand Down