Merge pull request #23694 from taosdata/fix/TD-27290

fix: change query killed error msg
This commit is contained in:
dapan1121 2023-11-15 08:28:30 +08:00 committed by GitHub
commit 14695cb685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 8 deletions

View File

@ -640,6 +640,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_SCH_IGNORE_ERROR TAOS_DEF_ERROR_CODE(0, 0x2503) #define TSDB_CODE_SCH_IGNORE_ERROR TAOS_DEF_ERROR_CODE(0, 0x2503)
#define TSDB_CODE_SCH_TIMEOUT_ERROR TAOS_DEF_ERROR_CODE(0, 0x2504) #define TSDB_CODE_SCH_TIMEOUT_ERROR TAOS_DEF_ERROR_CODE(0, 0x2504)
#define TSDB_CODE_SCH_JOB_IS_DROPPING TAOS_DEF_ERROR_CODE(0, 0x2505) #define TSDB_CODE_SCH_JOB_IS_DROPPING TAOS_DEF_ERROR_CODE(0, 0x2505)
#define TSDB_CODE_SCH_JOB_NOT_EXISTS TAOS_DEF_ERROR_CODE(0, 0x2506)
//parser //parser
#define TSDB_CODE_PAR_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x2600) #define TSDB_CODE_PAR_SYNTAX_ERROR TAOS_DEF_ERROR_CODE(0, 0x2600)

View File

@ -68,7 +68,7 @@ int32_t schHandleOpBeginEvent(int64_t jobId, SSchJob** job, SCH_OP_TYPE type, SS
SSchJob* pJob = schAcquireJob(jobId); SSchJob* pJob = schAcquireJob(jobId);
if (NULL == pJob) { if (NULL == pJob) {
qDebug("Acquire sch job failed, may be dropped, jobId:0x%" PRIx64, jobId); qDebug("Acquire sch job failed, may be dropped, jobId:0x%" PRIx64, jobId);
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); SCH_ERR_RET(TSDB_CODE_SCH_JOB_NOT_EXISTS);
} }
*job = pJob; *job = pJob;

View File

@ -504,6 +504,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SCH_STATUS_ERROR, "scheduler status erro
TAOS_DEFINE_ERROR(TSDB_CODE_SCH_INTERNAL_ERROR, "scheduler internal error") TAOS_DEFINE_ERROR(TSDB_CODE_SCH_INTERNAL_ERROR, "scheduler internal error")
TAOS_DEFINE_ERROR(TSDB_CODE_SCH_TIMEOUT_ERROR, "Task timeout") TAOS_DEFINE_ERROR(TSDB_CODE_SCH_TIMEOUT_ERROR, "Task timeout")
TAOS_DEFINE_ERROR(TSDB_CODE_SCH_JOB_IS_DROPPING, "Job is dropping") TAOS_DEFINE_ERROR(TSDB_CODE_SCH_JOB_IS_DROPPING, "Job is dropping")
TAOS_DEFINE_ERROR(TSDB_CODE_SCH_JOB_NOT_EXISTS, "Job no longer exist")
// parser // parser
TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYNTAX_ERROR, "syntax error near") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYNTAX_ERROR, "syntax error near")

View File

@ -62,6 +62,8 @@ static void shellCleanup(void *arg);
static void *shellCancelHandler(void *arg); static void *shellCancelHandler(void *arg);
static void *shellThreadLoop(void *arg); static void *shellThreadLoop(void *arg);
static bool shellCmdkilled = false;
bool shellIsEmptyCommand(const char *cmd) { bool shellIsEmptyCommand(const char *cmd) {
for (char c = *cmd++; c != 0; c = *cmd++) { for (char c = *cmd++; c != 0; c = *cmd++) {
if (c != ' ' && c != '\t' && c != ';') { if (c != ' ' && c != '\t' && c != ';') {
@ -72,6 +74,8 @@ bool shellIsEmptyCommand(const char *cmd) {
} }
int32_t shellRunSingleCommand(char *command) { int32_t shellRunSingleCommand(char *command) {
shellCmdkilled = false;
if (shellIsEmptyCommand(command)) { if (shellIsEmptyCommand(command)) {
return 0; return 0;
} }
@ -257,7 +261,8 @@ void shellRunSingleCommandImp(char *command) {
if (error_no == 0) { if (error_no == 0) {
printf("Query OK, %"PRId64 " row(s) in set (%.6fs)\r\n", numOfRows, (et - st) / 1E6); printf("Query OK, %"PRId64 " row(s) in set (%.6fs)\r\n", numOfRows, (et - st) / 1E6);
} else { } else {
printf("Query interrupted (%s), %"PRId64 " row(s) in set (%.6fs)\r\n", taos_errstr(pSql), numOfRows, (et - st) / 1E6); terrno = error_no;
printf("Query interrupted (%s), %"PRId64 " row(s) in set (%.6fs)\r\n", taos_errstr(NULL), numOfRows, (et - st) / 1E6);
} }
taos_free_result(pSql); taos_free_result(pSql);
} else { } else {
@ -952,7 +957,11 @@ void shellDumpResultCallback(void *param, TAOS_RES *tres, int num_of_rows) {
} }
} }
dump_info->numOfAllRows += num_of_rows; dump_info->numOfAllRows += num_of_rows;
if (!shellCmdkilled) {
taos_fetch_rows_a(tres, shellDumpResultCallback, param); taos_fetch_rows_a(tres, shellDumpResultCallback, param);
} else {
tsem_post(&dump_info->sem);
}
} else { } else {
if (num_of_rows < 0) { if (num_of_rows < 0) {
printf("\033[31masync retrieve failed, code: %d\033[0m\n", num_of_rows); printf("\033[31masync retrieve failed, code: %d\033[0m\n", num_of_rows);
@ -967,13 +976,15 @@ int64_t shellDumpResult(TAOS_RES *tres, char *fname, int32_t *error_no, bool ver
num_of_rows = shellDumpResultToFile(fname, tres); num_of_rows = shellDumpResultToFile(fname, tres);
} else { } else {
tsDumpInfo dump_info; tsDumpInfo dump_info;
if (!shellCmdkilled) {
init_dump_info(&dump_info, tres, sql, vertical); init_dump_info(&dump_info, tres, sql, vertical);
taos_fetch_rows_a(tres, shellDumpResultCallback, &dump_info); taos_fetch_rows_a(tres, shellDumpResultCallback, &dump_info);
tsem_wait(&dump_info.sem); tsem_wait(&dump_info.sem);
num_of_rows = dump_info.numOfAllRows; num_of_rows = dump_info.numOfAllRows;
} }
}
*error_no = taos_errno(tres); *error_no = shellCmdkilled ? TSDB_CODE_TSC_QUERY_KILLED : taos_errno(tres);
return num_of_rows; return num_of_rows;
} }
@ -1197,6 +1208,7 @@ void *shellCancelHandler(void *arg) {
} else { } else {
#endif #endif
if (shell.conn) { if (shell.conn) {
shellCmdkilled = true;
taos_kill_query(shell.conn); taos_kill_query(shell.conn);
} }
#ifdef WEBSOCKET #ifdef WEBSOCKET