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 @@ -151,6 +151,7 @@ public enum TSStatusCode {
CANNOT_FETCH_FI_STATE(722),
REPEATED_RPC_CALL(723),
CANNOT_READ_TSFILE(724),
COPY_TO_WRITE_ERROR(725),

// OBJECT
OBJECT_NOT_EXISTS(740),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2428,6 +2428,10 @@ public final class DataNodeQueryMessages {
"Duplicate tag column in TAGS clause: %s";
public static final String EXCEPTION_DUPLICATE_OPTION_IN_COPY_TO_STATEMENT_ARG_99CFE09F =
"Duplicate option in COPY TO statement: %s";
public static final String EXCEPTION_FAILED_TO_WRITE_THE_TARGET_FILE_ARG_5AC3025D =
"Failed to write the target file: %s";
public static final String LOG_FAILED_TO_WRITE_THE_TARGET_FILE_DURING_COPY_TO_EE25EF37 =
"Failed to write the target file during COPY TO";
public static final String SIMULTANEOUS_SETTING_OF_MONTHLY_AND_NON_MONTHLY_INTERVALS_IS_NOT_SUPPORTED =
"Simultaneous setting of monthly and non-monthly intervals is not supported.";
public static final String DON_T_NEED_TO_SPECIFY_TIME_COLUMN_WHILE_EITHER_TIME_BOUND_OR_FILL_GROUP_PARAMETER_IS_NOT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2803,6 +2803,10 @@ public final class DataNodeQueryMessages {
"TAGS 子句中存在重复的 TAG 列:%s";
public static final String EXCEPTION_DUPLICATE_OPTION_IN_COPY_TO_STATEMENT_ARG_99CFE09F =
"COPY TO 语句中存在重复的选项:%s";
public static final String EXCEPTION_FAILED_TO_WRITE_THE_TARGET_FILE_ARG_5AC3025D =
"写入目标文件失败:%s";
public static final String LOG_FAILED_TO_WRITE_THE_TARGET_FILE_DURING_COPY_TO_EE25EF37 =
"COPY TO 写入目标文件失败";
public static final String SIMULTANEOUS_SETTING_OF_MONTHLY_AND_NON_MONTHLY_INTERVALS_IS_NOT_SUPPORTED =
"不支持同时设置月级和非月级时间间隔。";
public static final String DON_T_NEED_TO_SPECIFY_TIME_COLUMN_WHILE_EITHER_TIME_BOUND_OR_FILL_GROUP_PARAMETER_IS_NOT =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,30 @@

import org.apache.iotdb.calc.execution.operator.Operator;
import org.apache.iotdb.calc.execution.operator.process.ProcessOperator;
import org.apache.iotdb.commons.exception.IoTDBRuntimeException;
import org.apache.iotdb.commons.queryengine.execution.MemoryEstimationHelper;
import org.apache.iotdb.commons.schema.column.ColumnHeader;
import org.apache.iotdb.db.i18n.DataNodeQueryMessages;
import org.apache.iotdb.db.queryengine.execution.operator.OperatorContext;
import org.apache.iotdb.db.queryengine.execution.operator.process.copyto.tsfile.CopyToTsFileOptions;
import org.apache.iotdb.db.queryengine.execution.operator.process.copyto.tsfile.TsFileFormatCopyToWriter;
import org.apache.iotdb.db.storageengine.rescon.disk.TierManager;
import org.apache.iotdb.rpc.TSStatusCode;

import com.google.common.util.concurrent.ListenableFuture;
import org.apache.tsfile.common.conf.TSFileDescriptor;
import org.apache.tsfile.read.common.block.TsBlock;
import org.apache.tsfile.utils.RamUsageEstimator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.List;

public class TableCopyToOperator implements ProcessOperator {
private static final Logger LOGGER = LoggerFactory.getLogger(TableCopyToOperator.class);
private static final long INSTANCE_SIZE =
RamUsageEstimator.shallowSizeOfInstance(TableCopyToOperator.class);

Expand Down Expand Up @@ -79,7 +84,11 @@ public OperatorContext getOperatorContext() {
public TsBlock next() throws Exception {
IFormatCopyToWriter formatWriter = getWriter();
if (!childOperator.hasNext()) {
formatWriter.seal();
try {
formatWriter.seal();
} catch (IOException e) {
throw newCopyToWriteError(e);
}
isFinished = true;
return formatWriter.buildResultTsBlock();
}
Expand All @@ -88,10 +97,24 @@ public TsBlock next() throws Exception {
return null;
}
hasData = true;
formatWriter.write(tsBlock);
try {
formatWriter.write(tsBlock);
} catch (IOException e) {
throw newCopyToWriteError(e);
}
return null;
}

private IoTDBRuntimeException newCopyToWriteError(IOException e) {
LOGGER.warn(
DataNodeQueryMessages.LOG_FAILED_TO_WRITE_THE_TARGET_FILE_DURING_COPY_TO_EE25EF37, e);
return new IoTDBRuntimeException(
String.format(
DataNodeQueryMessages.EXCEPTION_FAILED_TO_WRITE_THE_TARGET_FILE_ARG_5AC3025D,
e.getMessage()),
TSStatusCode.COPY_TO_WRITE_ERROR.getStatusCode());
}

private IFormatCopyToWriter getWriter() throws Exception {
if (writer != null) {
return writer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ public TsFileFormatCopyToWriter(

@Override
public void write(TsBlock tsBlock) throws Exception {
tsFileWriter.get().write(tsBlock);
try {
tsFileWriter.get().write(tsBlock);
} catch (Exception e) {
tsFileWriter = null;
throw e;
}
}

@Override
Expand All @@ -145,11 +150,14 @@ public void seal() throws Exception {
return;
}
TableTsBlock2TsFileWriter writer = tsFileWriter.get();
writer.close();
// should call these methods after writer.close()
deviceCount = writer.getDeviceCount();
rowCount = writer.getRowCount();
tsFileWriter = null;
try {
writer.close();
// should call these methods after writer.close()
deviceCount = writer.getDeviceCount();
rowCount = writer.getRowCount();
} finally {
tsFileWriter = null;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ public static TSStatus onQueryException(Exception e, String operation, TSStatusC
|| status.getCode() == TSStatusCode.PATH_ALREADY_EXIST.getStatusCode()
|| status.getCode() == TSStatusCode.PIPE_NOT_EXIST_ERROR.getStatusCode()
|| status.getCode() == TSStatusCode.QUERY_TIMEOUT.getStatusCode()
|| status.getCode() == TSStatusCode.CANNOT_READ_TSFILE.getStatusCode()) {
|| status.getCode() == TSStatusCode.CANNOT_READ_TSFILE.getStatusCode()
|| status.getCode() == TSStatusCode.COPY_TO_WRITE_ERROR.getStatusCode()) {
LOGGER.info(message);
} else {
LOGGER.warn(message, e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ private UtilMessages() {}
public static final String MESSAGE_MEET_ERROR_CLOSE_OPERATION_1C7D0589 = "Meet error in close operation.";
public static final String MESSAGE_FAIL_DO_NON_QUERY_OPERATIONS_BECAUSE_SYSTEM_READ_ONLY_10CA1ED2 = "Fail to do non-query operations because system is read-only.";
public static final String MESSAGE_DISK_SPACE_INSUFFICIENT_DF6205B0 = "Disk space is insufficient.";
public static final String MESSAGE_FAILED_TO_WRITE_THE_TARGET_FILE_4C48CE25 =
"Failed to write the target file.";
public static final String MESSAGE_MEET_ERROR_STARTING_UP_22A4CBFE = "Meet error while starting up.";
public static final String MESSAGE_USERNAME_PASSWORD_WRONG_C44C4AF0 = "Username or password is wrong.";
public static final String MESSAGE_HAS_NOT_LOGGED_A2BA0267 = "Has not logged in.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ private UtilMessages() {}
public static final String MESSAGE_MEET_ERROR_CLOSE_OPERATION_1C7D0589 = "关闭操作中发生错误。";
public static final String MESSAGE_FAIL_DO_NON_QUERY_OPERATIONS_BECAUSE_SYSTEM_READ_ONLY_10CA1ED2 = "系统只读,无法执行非查询操作。";
public static final String MESSAGE_DISK_SPACE_INSUFFICIENT_DF6205B0 = "磁盘空间不足。";
public static final String MESSAGE_FAILED_TO_WRITE_THE_TARGET_FILE_4C48CE25 =
"写入目标文件失败。";
public static final String MESSAGE_MEET_ERROR_STARTING_UP_22A4CBFE = "启动时发生错误。";
public static final String MESSAGE_USERNAME_PASSWORD_WRONG_C44C4AF0 = "用户名或密码错误。";
public static final String MESSAGE_HAS_NOT_LOGGED_A2BA0267 = "尚未登录。";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ public static TSStatus getStatus(TSStatusCode statusCode) {
case DISK_SPACE_INSUFFICIENT:
status.setMessage(UtilMessages.MESSAGE_DISK_SPACE_INSUFFICIENT_DF6205B0);
break;
case COPY_TO_WRITE_ERROR:
status.setMessage(UtilMessages.MESSAGE_FAILED_TO_WRITE_THE_TARGET_FILE_4C48CE25);
break;
case START_UP_ERROR:
status.setMessage(UtilMessages.MESSAGE_MEET_ERROR_STARTING_UP_22A4CBFE);
break;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
<thrift.version>0.23.0</thrift.version>
<xz.version>1.9</xz.version>
<zstd-jni.version>1.5.6-3</zstd-jni.version>
<tsfile.version>2.3.2-260731-SNAPSHOT</tsfile.version>
<tsfile.version>2.4.1-260806-SNAPSHOT</tsfile.version>
<i18n.locale>en</i18n.locale>
<tsfile.locale.opt/>
</properties>
Expand Down
Loading