Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

branch-2.1: [Fix](Job)The INSERT execution failed, but the task record status is marked as successful. #44292 #44443

Merged
merged 1 commit into from
Nov 22, 2024
Merged
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 @@ -22,6 +22,7 @@
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.ScalarType;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.common.util.Util;
import org.apache.doris.job.exception.JobException;
import org.apache.doris.job.task.AbstractTask;
import org.apache.doris.load.FailMsg;
Expand All @@ -30,6 +31,7 @@
import org.apache.doris.nereids.parser.NereidsParser;
import org.apache.doris.nereids.trees.plans.commands.insert.InsertIntoTableCommand;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.QueryState;
import org.apache.doris.qe.StmtExecutor;
import org.apache.doris.thrift.TCell;
import org.apache.doris.thrift.TRow;
Expand Down Expand Up @@ -195,10 +197,13 @@ public void run() throws JobException {
return;
}
command.runWithUpdateInfo(ctx, stmtExecutor, loadStatistic);
if (ctx.getState().getStateType() != QueryState.MysqlStateType.OK) {
throw new JobException(ctx.getState().getErrorMessage());
}
} catch (Exception e) {
log.warn("execute insert task error, job id is {}, task id is {},sql is {}", getJobId(),
getTaskId(), sql, e);
throw new JobException(e);
throw new JobException(Util.getRootCauseMessage(e));
}
}

Expand Down Expand Up @@ -237,15 +242,7 @@ public TRow getTvfInfo(String jobName) {
trow.addToColumnValue(new TCell().setStringVal(jobName));
trow.addToColumnValue(new TCell().setStringVal(getJobId() + LABEL_SPLITTER + getTaskId()));
trow.addToColumnValue(new TCell().setStringVal(jobInfo.getState().name()));
// err msg
String errorMsg = "";
if (failMsg != null) {
errorMsg = failMsg.getMsg();
}
if (StringUtils.isNotBlank(getErrMsg())) {
errorMsg = getErrMsg();
}
trow.addToColumnValue(new TCell().setStringVal(errorMsg));
trow.addToColumnValue(new TCell().setStringVal(getErrorMsg()));
// create time
trow.addToColumnValue(new TCell().setStringVal(TimeUtils.longToTimeString(getCreateTimeMs())));
trow.addToColumnValue(new TCell().setStringVal(null == getStartTimeMs() ? ""
Expand Down Expand Up @@ -275,7 +272,7 @@ private TRow getPendingTaskTVFInfo(String jobName) {
trow.addToColumnValue(new TCell().setStringVal(jobName));
trow.addToColumnValue(new TCell().setStringVal(getJobId() + LABEL_SPLITTER + getTaskId()));
trow.addToColumnValue(new TCell().setStringVal(getStatus().name()));
trow.addToColumnValue(new TCell().setStringVal(""));
trow.addToColumnValue(new TCell().setStringVal(getErrorMsg()));
trow.addToColumnValue(new TCell().setStringVal(TimeUtils.longToTimeString(getCreateTimeMs())));
trow.addToColumnValue(new TCell().setStringVal(null == getStartTimeMs() ? ""
: TimeUtils.longToTimeString(getStartTimeMs())));
Expand All @@ -287,4 +284,15 @@ private TRow getPendingTaskTVFInfo(String jobName) {
return trow;
}

private String getErrorMsg() {
// err msg
String errorMsg = "";
if (failMsg != null) {
errorMsg = failMsg.getMsg();
}
if (StringUtils.isNotBlank(getErrMsg())) {
errorMsg = getErrMsg();
}
return errorMsg;
}
}
Loading