From fb07e8b73eb67bfc401379f6cbb1c6437e26943b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 7 Jun 2022 11:15:33 +0800 Subject: [PATCH] refactor:do some internal refactor and add some logs. --- source/client/src/clientImpl.c | 3 ++- source/client/src/clientMain.c | 11 +++++++---- source/libs/catalog/src/ctgAsync.c | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index c71c7d3487..7601e082e4 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -580,7 +580,8 @@ void schedulerExecCb(SQueryResult* pResult, void* param, int32_t code) { STscObj* pTscObj = pRequest->pTscObj; if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code)) { - tscDebug("0x%"PRIx64" client retry to handle the error, code:%s, reqId:0x%"PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); + tscDebug("0x%"PRIx64" client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code), + pRequest->retry, pRequest->requestId); pRequest->prevCode = code; doAsyncQuery(pRequest, true); return; diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index bcc9447fb3..3ca93d178c 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -629,8 +629,10 @@ void retrieveMetaCallback(SMetaData* pResultMeta, void* param, int32_t code) { taosMemoryFree(pWrapper); launchAsyncQuery(pRequest, pQuery); } else { + tscDebug("error happens, code:%d", code); if (NEED_CLIENT_HANDLE_ERROR(code)) { - tscDebug("0x%"PRIx64" client retry to handle the error, code:%s, reqId:0x%"PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); + tscDebug("0x%"PRIx64" client retry to handle the error, code:%d - %s, tryCount:%d, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code), + pRequest->retry, pRequest->requestId); pRequest->prevCode = code; doAsyncQuery(pRequest, true); return; @@ -703,13 +705,14 @@ int32_t createParseContext(const SRequestObj *pRequest, SParseContext** pCxt) { void doAsyncQuery(SRequestObj* pRequest, bool updateMetaForce) { SParseContext* pCxt = NULL; STscObj *pTscObj = pRequest->pTscObj; + int32_t code = 0; if (pRequest->retry++ > REQUEST_TOTAL_EXEC_TIMES) { - pRequest->code = pRequest->prevCode; + code = pRequest->prevCode; goto _error; } - int32_t code = createParseContext(pRequest, &pCxt); + code = createParseContext(pRequest, &pCxt); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -746,7 +749,7 @@ void doAsyncQuery(SRequestObj* pRequest, bool updateMetaForce) { } _error: - tscError("0x%"PRIx64" error happens, code:%s, reqId:0x%"PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); + tscError("0x%"PRIx64" error happens, code:%d - %s, reqId:0x%"PRIx64, pRequest->self, code, tstrerror(code), pRequest->requestId); terrno = code; pRequest->code = code; pRequest->body.queryFp(pRequest->body.param, pRequest, code); diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index f43e559244..63df81e73c 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -559,7 +559,7 @@ int32_t ctgHandleTaskEnd(SCtgTask* pTask, int32_t rspCode) { SCtgJob* pJob = pTask->pJob; int32_t code = 0; - qDebug("QID:%" PRIx64 " task %d end with rsp %s", pJob->queryId, pTask->taskId, tstrerror(rspCode)); + qDebug("QID:0x%" PRIx64 " task %d end with rsp %s", pJob->queryId, pTask->taskId, tstrerror(rspCode)); if (rspCode) { int32_t lastCode = atomic_val_compare_exchange_32(&pJob->rspCode, 0, rspCode); @@ -572,7 +572,7 @@ int32_t ctgHandleTaskEnd(SCtgTask* pTask, int32_t rspCode) { int32_t taskDone = atomic_add_fetch_32(&pJob->taskDone, 1); if (taskDone < taosArrayGetSize(pJob->pTasks)) { - qDebug("task done: %d, total: %d", taskDone, (int32_t)taosArrayGetSize(pJob->pTasks)); + qDebug("QID:0x%" PRIx64 " task done: %d, total: %d", pJob->queryId, taskDone, (int32_t)taosArrayGetSize(pJob->pTasks)); return TSDB_CODE_SUCCESS; }