[fix] Fix bug that wrong exception message returned by insert statement (#7832)

`insert` statement may return exception message `Execute timeout` after load data failed.
But the real reason is that there exists unhealthy backend, not execute timeout.

```
MySQL [ssb]> insert into lineorder_flat select * from lineorder_flat;
ERROR 1105 (HY000): errCode = 2, detailMessage = Execute timeout
```
This commit is contained in:
weizuo93
2022-01-24 21:11:45 +08:00
committed by GitHub
parent 4e9bc5cb65
commit be9ebbc14d

View File

@ -1248,10 +1248,15 @@ public class StmtExecutor implements ProfileWriter {
coord.exec();
coord.join(context.getSessionVariable().getQueryTimeoutS());
boolean notTimeout = coord.join(context.getSessionVariable().getQueryTimeoutS());
if (!coord.isDone()) {
coord.cancel();
ErrorReport.reportDdlException(ErrorCode.ERR_EXECUTE_TIMEOUT);
if (notTimeout) {
errMsg = coord.getExecStatus().getErrorMsg();
ErrorReport.reportDdlException("There exists unhealthy backend. " + errMsg, ErrorCode.ERR_FAILED_WHEN_INSERT);
} else {
ErrorReport.reportDdlException(ErrorCode.ERR_EXECUTE_TIMEOUT);
}
}
if (!coord.getExecStatus().ok()) {