Merge branch 'feat/TD-30268' of github.com:taosdata/TDengine into feat/TD-30268
This commit is contained in:
commit
e40daae3fc
|
@ -47,7 +47,7 @@ typedef int32_t (*GetQueueSizeFp)(void* pMgmt, int32_t vgId, EQueueType qtype);
|
||||||
typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg);
|
typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg);
|
||||||
typedef void (*SendRspFp)(SRpcMsg* pMsg);
|
typedef void (*SendRspFp)(SRpcMsg* pMsg);
|
||||||
typedef void (*RegisterBrokenLinkArgFp)(struct SRpcMsg* pMsg);
|
typedef void (*RegisterBrokenLinkArgFp)(struct SRpcMsg* pMsg);
|
||||||
typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type);
|
typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type, int32_t status);
|
||||||
typedef void (*ReportStartup)(const char* name, const char* desc);
|
typedef void (*ReportStartup)(const char* name, const char* desc);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -76,7 +76,7 @@ int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg);
|
||||||
int32_t tmsgSendSyncReq(const SEpSet* epSet, SRpcMsg* pMsg);
|
int32_t tmsgSendSyncReq(const SEpSet* epSet, SRpcMsg* pMsg);
|
||||||
void tmsgSendRsp(SRpcMsg* pMsg);
|
void tmsgSendRsp(SRpcMsg* pMsg);
|
||||||
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg);
|
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg);
|
||||||
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type);
|
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type, int32_t code);
|
||||||
void tmsgReportStartup(const char* name, const char* desc);
|
void tmsgReportStartup(const char* name, const char* desc);
|
||||||
bool tmsgUpdateDnodeInfo(int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port);
|
bool tmsgUpdateDnodeInfo(int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port);
|
||||||
void tmsgUpdateDnodeEpSet(SEpSet* epset);
|
void tmsgUpdateDnodeEpSet(SEpSet* epset);
|
||||||
|
|
|
@ -171,7 +171,7 @@ void *rpcReallocCont(void *ptr, int64_t contLen);
|
||||||
int32_t rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
|
int32_t rpcSendRequest(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid);
|
||||||
int32_t rpcSendResponse(const SRpcMsg *pMsg);
|
int32_t rpcSendResponse(const SRpcMsg *pMsg);
|
||||||
int32_t rpcRegisterBrokenLinkArg(SRpcMsg *msg);
|
int32_t rpcRegisterBrokenLinkArg(SRpcMsg *msg);
|
||||||
int32_t rpcReleaseHandle(void *handle, int8_t type); // just release conn to rpc instance, no close sock
|
int32_t rpcReleaseHandle(void *handle, int8_t type, int32_t code); // just release conn to rpc instance, no close sock
|
||||||
|
|
||||||
// These functions will not be called in the child process
|
// These functions will not be called in the child process
|
||||||
int32_t rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);
|
int32_t rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *rid, SRpcCtx *ctx);
|
||||||
|
|
|
@ -368,7 +368,9 @@ static inline int32_t dmSendSyncReq(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
||||||
|
|
||||||
static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { (void)rpcRegisterBrokenLinkArg(pMsg); }
|
static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { (void)rpcRegisterBrokenLinkArg(pMsg); }
|
||||||
|
|
||||||
static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { (void)rpcReleaseHandle(pHandle, type); }
|
static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type, int32_t status) {
|
||||||
|
(void)rpcReleaseHandle(pHandle, type, status);
|
||||||
|
}
|
||||||
|
|
||||||
static bool rpcRfp(int32_t code, tmsg_t msgType) {
|
static bool rpcRfp(int32_t code, tmsg_t msgType) {
|
||||||
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND ||
|
if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND ||
|
||||||
|
|
|
@ -289,7 +289,7 @@ void qwFreeTaskHandle(SQWTaskCtx *ctx) {
|
||||||
|
|
||||||
void qwFreeSinkHandle(SQWTaskCtx *ctx) {
|
void qwFreeSinkHandle(SQWTaskCtx *ctx) {
|
||||||
// Note: free/kill may in RC
|
// Note: free/kill may in RC
|
||||||
void* osinkHandle = atomic_load_ptr(&ctx->sinkHandle);
|
void *osinkHandle = atomic_load_ptr(&ctx->sinkHandle);
|
||||||
if (osinkHandle && osinkHandle == atomic_val_compare_exchange_ptr(&ctx->sinkHandle, osinkHandle, NULL)) {
|
if (osinkHandle && osinkHandle == atomic_val_compare_exchange_ptr(&ctx->sinkHandle, osinkHandle, NULL)) {
|
||||||
QW_SINK_ENABLE_MEMPOOL(ctx);
|
QW_SINK_ENABLE_MEMPOOL(ctx);
|
||||||
dsDestroyDataSinker(osinkHandle);
|
dsDestroyDataSinker(osinkHandle);
|
||||||
|
@ -317,7 +317,7 @@ int32_t qwKillTaskHandle(SQWTaskCtx *ctx, int32_t rspCode) {
|
||||||
|
|
||||||
void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
void qwFreeTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
||||||
if (ctx->ctrlConnInfo.handle) {
|
if (ctx->ctrlConnInfo.handle) {
|
||||||
tmsgReleaseHandle(&ctx->ctrlConnInfo, TAOS_CONN_SERVER);
|
tmsgReleaseHandle(&ctx->ctrlConnInfo, TAOS_CONN_SERVER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->ctrlConnInfo.handle = NULL;
|
ctx->ctrlConnInfo.handle = NULL;
|
||||||
|
@ -341,20 +341,19 @@ static void freeExplainExecItem(void *param) {
|
||||||
taosMemoryFree(pInfo->verboseInfo);
|
taosMemoryFree(pInfo->verboseInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qwSendExplainResponse(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
int32_t qwSendExplainResponse(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
qTaskInfo_t taskHandle = ctx->taskHandle;
|
qTaskInfo_t taskHandle = ctx->taskHandle;
|
||||||
|
|
||||||
ctx->explainRsped = true;
|
ctx->explainRsped = true;
|
||||||
|
|
||||||
SArray *execInfoList = taosArrayInit(4, sizeof(SExplainExecInfo));
|
SArray *execInfoList = taosArrayInit(4, sizeof(SExplainExecInfo));
|
||||||
if (NULL == execInfoList) {
|
if (NULL == execInfoList) {
|
||||||
QW_ERR_JRET(terrno);
|
QW_ERR_JRET(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
QW_ERR_JRET(qGetExplainExecInfo(taskHandle, execInfoList));
|
QW_ERR_JRET(qGetExplainExecInfo(taskHandle, execInfoList));
|
||||||
|
|
||||||
if (ctx->localExec) {
|
if (ctx->localExec) {
|
||||||
SExplainLocalRsp localRsp = {0};
|
SExplainLocalRsp localRsp = {0};
|
||||||
localRsp.rsp.numOfPlans = taosArrayGetSize(execInfoList);
|
localRsp.rsp.numOfPlans = taosArrayGetSize(execInfoList);
|
||||||
|
@ -372,7 +371,7 @@ int32_t qwSendExplainResponse(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
||||||
if (NULL == taosArrayPush(ctx->explainRes, &localRsp)) {
|
if (NULL == taosArrayPush(ctx->explainRes, &localRsp)) {
|
||||||
QW_ERR_JRET(terrno);
|
QW_ERR_JRET(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(execInfoList);
|
taosArrayDestroy(execInfoList);
|
||||||
execInfoList = NULL;
|
execInfoList = NULL;
|
||||||
} else {
|
} else {
|
||||||
|
@ -392,8 +391,6 @@ _return:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32_t qwDropTaskCtx(QW_FPARAMS_DEF) {
|
int32_t qwDropTaskCtx(QW_FPARAMS_DEF) {
|
||||||
char id[sizeof(qId) + sizeof(cId) + sizeof(tId) + sizeof(eId)] = {0};
|
char id[sizeof(qId) + sizeof(cId) + sizeof(tId) + sizeof(eId)] = {0};
|
||||||
QW_SET_QTID(id, qId, cId, tId, eId);
|
QW_SET_QTID(id, qId, cId, tId, eId);
|
||||||
|
@ -482,7 +479,6 @@ _return:
|
||||||
QW_RET(code);
|
QW_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t qwHandleDynamicTaskEnd(QW_FPARAMS_DEF) {
|
int32_t qwHandleDynamicTaskEnd(QW_FPARAMS_DEF) {
|
||||||
char id[sizeof(qId) + sizeof(cId) + sizeof(tId) + sizeof(eId)] = {0};
|
char id[sizeof(qId) + sizeof(cId) + sizeof(tId) + sizeof(eId)] = {0};
|
||||||
QW_SET_QTID(id, qId, cId, tId, eId);
|
QW_SET_QTID(id, qId, cId, tId, eId);
|
||||||
|
@ -543,16 +539,17 @@ void qwSetHbParam(int64_t refId, SQWHbParam **pParam) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx) {
|
int32_t qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx) {
|
||||||
char dbFName[TSDB_DB_FNAME_LEN];
|
char dbFName[TSDB_DB_FNAME_LEN];
|
||||||
char tbName[TSDB_TABLE_NAME_LEN];
|
char tbName[TSDB_TABLE_NAME_LEN];
|
||||||
STbVerInfo tbInfo;
|
STbVerInfo tbInfo;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
bool tbGet = false;
|
bool tbGet = false;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
tbGet = false;
|
tbGet = false;
|
||||||
code = qGetQueryTableSchemaVersion(pTaskInfo, dbFName, TSDB_DB_FNAME_LEN, tbName, TSDB_TABLE_NAME_LEN, &tbInfo.sversion, &tbInfo.tversion, i, &tbGet);
|
code = qGetQueryTableSchemaVersion(pTaskInfo, dbFName, TSDB_DB_FNAME_LEN, tbName, TSDB_TABLE_NAME_LEN,
|
||||||
|
&tbInfo.sversion, &tbInfo.tversion, i, &tbGet);
|
||||||
if (TSDB_CODE_SUCCESS != code || !tbGet) {
|
if (TSDB_CODE_SUCCESS != code || !tbGet) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -569,11 +566,11 @@ int32_t qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx) {
|
||||||
QW_ERR_RET(terrno);
|
QW_ERR_RET(terrno);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == taosArrayPush(ctx->tbInfo, &tbInfo)) {
|
if (NULL == taosArrayPush(ctx->tbInfo, &tbInfo)) {
|
||||||
QW_ERR_RET(terrno);
|
QW_ERR_RET(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,7 +582,7 @@ void qwCloseRef(void) {
|
||||||
if (atomic_load_32(&gQwMgmt.qwNum) <= 0 && gQwMgmt.qwRef >= 0) {
|
if (atomic_load_32(&gQwMgmt.qwNum) <= 0 && gQwMgmt.qwRef >= 0) {
|
||||||
taosCloseRef(gQwMgmt.qwRef); // ignore error
|
taosCloseRef(gQwMgmt.qwRef); // ignore error
|
||||||
gQwMgmt.qwRef = -1;
|
gQwMgmt.qwRef = -1;
|
||||||
|
|
||||||
taosHashCleanup(gQueryMgmt.pJobInfo);
|
taosHashCleanup(gQueryMgmt.pJobInfo);
|
||||||
gQueryMgmt.pJobInfo = NULL;
|
gQueryMgmt.pJobInfo = NULL;
|
||||||
}
|
}
|
||||||
|
@ -606,7 +603,7 @@ void qwDestroyImpl(void *pMgmt) {
|
||||||
if (taosTmrStop(mgmt->hbTimer)) {
|
if (taosTmrStop(mgmt->hbTimer)) {
|
||||||
qTrace("stop qworker hb timer may failed");
|
qTrace("stop qworker hb timer may failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
mgmt->hbTimer = NULL;
|
mgmt->hbTimer = NULL;
|
||||||
taosTmrCleanUp(mgmt->timer);
|
taosTmrCleanUp(mgmt->timer);
|
||||||
|
|
||||||
|
@ -620,7 +617,7 @@ void qwDestroyImpl(void *pMgmt) {
|
||||||
void *key = taosHashGetKey(pIter, NULL);
|
void *key = taosHashGetKey(pIter, NULL);
|
||||||
QW_GET_QTID(key, qId, cId, tId, eId);
|
QW_GET_QTID(key, qId, cId, tId, eId);
|
||||||
sId = ctx->sId;
|
sId = ctx->sId;
|
||||||
|
|
||||||
qwFreeTaskCtx(QW_FPARAMS(), ctx);
|
qwFreeTaskCtx(QW_FPARAMS(), ctx);
|
||||||
QW_TASK_DLOG_E("task ctx freed");
|
QW_TASK_DLOG_E("task ctx freed");
|
||||||
pIter = taosHashIterate(mgmt->ctxHash, pIter);
|
pIter = taosHashIterate(mgmt->ctxHash, pIter);
|
||||||
|
@ -732,12 +729,12 @@ void qwClearExpiredSch(SQWorker *mgmt, SArray *pExpiredSch) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qwDestroyJobInfo(void* job) {
|
void qwDestroyJobInfo(void *job) {
|
||||||
if (NULL == job) {
|
if (NULL == job) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQWJobInfo* pJob = (SQWJobInfo*)job;
|
SQWJobInfo *pJob = (SQWJobInfo *)job;
|
||||||
|
|
||||||
taosMemoryFreeClear(pJob->memInfo);
|
taosMemoryFreeClear(pJob->memInfo);
|
||||||
taosHashCleanup(pJob->pSessions);
|
taosHashCleanup(pJob->pSessions);
|
||||||
|
@ -758,7 +755,7 @@ bool qwStopTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool forceStop, int32_t errC
|
||||||
|
|
||||||
return resFreed;
|
return resFreed;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QW_QUERY_RUNNING(ctx)) {
|
if (QW_QUERY_RUNNING(ctx)) {
|
||||||
code = qwKillTaskHandle(ctx, errCode);
|
code = qwKillTaskHandle(ctx, errCode);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
|
@ -793,7 +790,7 @@ bool qwStopTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool forceStop, int32_t errC
|
||||||
QW_TASK_DLOG_E("task resources freed");
|
QW_TASK_DLOG_E("task resources freed");
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
||||||
|
|
||||||
return resFreed;
|
return resFreed;
|
||||||
|
@ -814,15 +811,15 @@ bool qwRetireTask(QW_FPARAMS_DEF, int32_t errCode) {
|
||||||
return retired;
|
return retired;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool qwRetireJob(SQWJobInfo* pJob) {
|
bool qwRetireJob(SQWJobInfo *pJob) {
|
||||||
if (NULL == pJob) {
|
if (NULL == pJob) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool retired = true;
|
bool retired = true;
|
||||||
void* pIter = taosHashIterate(pJob->pSessions, NULL);
|
void *pIter = taosHashIterate(pJob->pSessions, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SQWSessionInfo* pSession = (SQWSessionInfo*)pIter;
|
SQWSessionInfo *pSession = (SQWSessionInfo *)pIter;
|
||||||
|
|
||||||
if (!qwRetireTask((SQWorker *)pSession->mgmt, pSession->sId, pSession->qId, pSession->cId, pSession->tId, pSession->rId, pSession->eId, pJob->errCode)) {
|
if (!qwRetireTask((SQWorker *)pSession->mgmt, pSession->sId, pSession->qId, pSession->cId, pSession->tId, pSession->rId, pSession->eId, pJob->errCode)) {
|
||||||
retired = false;
|
retired = false;
|
||||||
|
@ -833,4 +830,3 @@ bool qwRetireJob(SQWJobInfo* pJob) {
|
||||||
|
|
||||||
return retired;
|
return retired;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,8 @@ SQWorkerMgmt gQwMgmt = {
|
||||||
.qwNum = 0,
|
.qwNum = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
TdThreadOnce gQueryPoolInit = PTHREAD_ONCE_INIT;
|
TdThreadOnce gQueryPoolInit = PTHREAD_ONCE_INIT;
|
||||||
SQueryMgmt gQueryMgmt = {0};
|
SQueryMgmt gQueryMgmt = {0};
|
||||||
|
|
||||||
|
|
||||||
void qwStopAllTasks(SQWorker *mgmt) {
|
void qwStopAllTasks(SQWorker *mgmt) {
|
||||||
uint64_t qId, cId, tId, sId;
|
uint64_t qId, cId, tId, sId;
|
||||||
|
@ -53,7 +52,7 @@ int32_t qwProcessHbLinkBroken(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *re
|
||||||
sch->hbBrokenTs = taosGetTimestampMs();
|
sch->hbBrokenTs = taosGetTimestampMs();
|
||||||
|
|
||||||
if (qwMsg->connInfo.handle == sch->hbConnInfo.handle) {
|
if (qwMsg->connInfo.handle == sch->hbConnInfo.handle) {
|
||||||
tmsgReleaseHandle(&sch->hbConnInfo, TAOS_CONN_SERVER);
|
tmsgReleaseHandle(&sch->hbConnInfo, TAOS_CONN_SERVER, 0);
|
||||||
sch->hbConnInfo.handle = NULL;
|
sch->hbConnInfo.handle = NULL;
|
||||||
sch->hbConnInfo.ahandle = NULL;
|
sch->hbConnInfo.ahandle = NULL;
|
||||||
|
|
||||||
|
@ -71,8 +70,8 @@ int32_t qwProcessHbLinkBroken(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *re
|
||||||
|
|
||||||
int32_t qwHandleTaskComplete(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
int32_t qwHandleTaskComplete(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
||||||
qTaskInfo_t taskHandle = ctx->taskHandle;
|
qTaskInfo_t taskHandle = ctx->taskHandle;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
ctx->queryExecDone = true;
|
ctx->queryExecDone = true;
|
||||||
|
|
||||||
if (TASK_TYPE_TEMP == ctx->taskType && taskHandle) {
|
if (TASK_TYPE_TEMP == ctx->taskType && taskHandle) {
|
||||||
|
@ -90,7 +89,7 @@ int32_t qwHandleTaskComplete(QW_FPARAMS_DEF, SQWTaskCtx *ctx) {
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if ((!ctx->dynamicTask) && (!ctx->explain || ctx->explainRsped)) {
|
if ((!ctx->dynamicTask) && (!ctx->explain || ctx->explainRsped)) {
|
||||||
qwFreeTaskHandle(ctx);
|
qwFreeTaskHandle(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -131,7 +130,7 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) {
|
||||||
if (NULL == pResList) {
|
if (NULL == pResList) {
|
||||||
QW_ERR_RET(terrno);
|
QW_ERR_RET(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
QW_TASK_DLOG("start to execTask, loopIdx:%d", i++);
|
QW_TASK_DLOG("start to execTask, loopIdx:%d", i++);
|
||||||
|
|
||||||
|
@ -144,7 +143,7 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) {
|
||||||
taosEnableMemPoolUsage(ctx->memPoolSession);
|
taosEnableMemPoolUsage(ctx->memPoolSession);
|
||||||
code = qExecTaskOpt(taskHandle, pResList, &useconds, &hasMore, &localFetch);
|
code = qExecTaskOpt(taskHandle, pResList, &useconds, &hasMore, &localFetch);
|
||||||
taosDisableMemPoolUsage();
|
taosDisableMemPoolUsage();
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
if (code != TSDB_CODE_OPS_NOT_SUPPORT) {
|
if (code != TSDB_CODE_OPS_NOT_SUPPORT) {
|
||||||
QW_TASK_ELOG("qExecTask failed, code:%x - %s", code, tstrerror(code));
|
QW_TASK_ELOG("qExecTask failed, code:%x - %s", code, tstrerror(code));
|
||||||
|
@ -168,7 +167,7 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) {
|
||||||
QW_SINK_ENABLE_MEMPOOL(ctx);
|
QW_SINK_ENABLE_MEMPOOL(ctx);
|
||||||
code = dsPutDataBlock(sinkHandle, &inputData, &qcontinue);
|
code = dsPutDataBlock(sinkHandle, &inputData, &qcontinue);
|
||||||
QW_SINK_DISABLE_MEMPOOL();
|
QW_SINK_DISABLE_MEMPOOL();
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
QW_TASK_ELOG("dsPutDataBlock failed, code:%x - %s", code, tstrerror(code));
|
QW_TASK_ELOG("dsPutDataBlock failed, code:%x - %s", code, tstrerror(code));
|
||||||
QW_ERR_JRET(code);
|
QW_ERR_JRET(code);
|
||||||
|
@ -199,7 +198,7 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) {
|
||||||
QW_SINK_ENABLE_MEMPOOL(ctx);
|
QW_SINK_ENABLE_MEMPOOL(ctx);
|
||||||
dsEndPut(sinkHandle, useconds);
|
dsEndPut(sinkHandle, useconds);
|
||||||
QW_SINK_DISABLE_MEMPOOL();
|
QW_SINK_DISABLE_MEMPOOL();
|
||||||
|
|
||||||
if (queryStop) {
|
if (queryStop) {
|
||||||
*queryStop = true;
|
*queryStop = true;
|
||||||
}
|
}
|
||||||
|
@ -233,9 +232,9 @@ _return:
|
||||||
taosArrayDestroy(pResList);
|
taosArrayDestroy(pResList);
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
qwFreeTaskHandle(ctx);
|
qwFreeTaskHandle(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
QW_RET(code);
|
QW_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +250,7 @@ bool qwTaskNotInExec(SQWTaskCtx *ctx) {
|
||||||
int32_t qwGenerateSchHbRsp(SQWorker *mgmt, SQWSchStatus *sch, SQWHbInfo *hbInfo) {
|
int32_t qwGenerateSchHbRsp(SQWorker *mgmt, SQWSchStatus *sch, SQWHbInfo *hbInfo) {
|
||||||
int32_t taskNum = 0;
|
int32_t taskNum = 0;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
hbInfo->connInfo = sch->hbConnInfo;
|
hbInfo->connInfo = sch->hbConnInfo;
|
||||||
hbInfo->rsp.epId = sch->hbEpId;
|
hbInfo->rsp.epId = sch->hbEpId;
|
||||||
|
|
||||||
|
@ -318,7 +317,7 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen,
|
||||||
QW_SINK_ENABLE_MEMPOOL(ctx);
|
QW_SINK_ENABLE_MEMPOOL(ctx);
|
||||||
dsGetDataLength(ctx->sinkHandle, &len, &rawLen, &queryEnd);
|
dsGetDataLength(ctx->sinkHandle, &len, &rawLen, &queryEnd);
|
||||||
QW_SINK_DISABLE_MEMPOOL();
|
QW_SINK_DISABLE_MEMPOOL();
|
||||||
|
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
QW_TASK_ELOG("invalid length from dsGetDataLength, length:%" PRId64 "", len);
|
QW_TASK_ELOG("invalid length from dsGetDataLength, length:%" PRId64 "", len);
|
||||||
QW_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
QW_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
@ -417,7 +416,7 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen,
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
*rspMsg = pRsp;
|
*rspMsg = pRsp;
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +430,7 @@ int32_t qwGetDeleteResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SDeleteRes *pRes
|
||||||
QW_SINK_ENABLE_MEMPOOL(ctx);
|
QW_SINK_ENABLE_MEMPOOL(ctx);
|
||||||
dsGetDataLength(ctx->sinkHandle, &len, &rawLen, &queryEnd);
|
dsGetDataLength(ctx->sinkHandle, &len, &rawLen, &queryEnd);
|
||||||
QW_SINK_DISABLE_MEMPOOL();
|
QW_SINK_DISABLE_MEMPOOL();
|
||||||
|
|
||||||
if (len <= 0 || len != sizeof(SDeleterRes)) {
|
if (len <= 0 || len != sizeof(SDeleterRes)) {
|
||||||
QW_TASK_ELOG("invalid length from dsGetDataLength, length:%" PRId64, len);
|
QW_TASK_ELOG("invalid length from dsGetDataLength, length:%" PRId64, len);
|
||||||
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
@ -532,7 +531,7 @@ int32_t qwStartDynamicTaskNewExec(QW_FPARAMS_DEF, SQWTaskCtx *ctx, SQWMsg *qwMsg
|
||||||
QW_SINK_ENABLE_MEMPOOL(ctx);
|
QW_SINK_ENABLE_MEMPOOL(ctx);
|
||||||
dsReset(ctx->sinkHandle);
|
dsReset(ctx->sinkHandle);
|
||||||
QW_SINK_DISABLE_MEMPOOL();
|
QW_SINK_DISABLE_MEMPOOL();
|
||||||
|
|
||||||
qUpdateOperatorParam(ctx->taskHandle, qwMsg->msg);
|
qUpdateOperatorParam(ctx->taskHandle, qwMsg->msg);
|
||||||
|
|
||||||
QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_FETCH);
|
QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_FETCH);
|
||||||
|
@ -721,7 +720,8 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
(void)qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_FAIL, ctx->dynamicTask); // already in error, ignore new error
|
(void)qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_FAIL,
|
||||||
|
ctx->dynamicTask); // already in error, ignore new error
|
||||||
}
|
}
|
||||||
|
|
||||||
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
QW_UNLOCK(QW_WRITE, &ctx->lock);
|
||||||
|
@ -752,11 +752,11 @@ int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
ctx->ctrlConnInfo = qwMsg->connInfo;
|
ctx->ctrlConnInfo = qwMsg->connInfo;
|
||||||
ctx->sId = sId;
|
ctx->sId = sId;
|
||||||
ctx->phase = -1;
|
ctx->phase = -1;
|
||||||
|
|
||||||
if (NULL != gMemPoolHandle) {
|
if (NULL != gMemPoolHandle) {
|
||||||
QW_ERR_JRET(qwInitSession(QW_FPARAMS(), ctx, &ctx->memPoolSession));
|
QW_ERR_JRET(qwInitSession(QW_FPARAMS(), ctx, &ctx->memPoolSession));
|
||||||
}
|
}
|
||||||
|
|
||||||
QW_ERR_JRET(qwAddTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_INIT));
|
QW_ERR_JRET(qwAddTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_INIT));
|
||||||
|
|
||||||
QW_ERR_JRET(qwSendQueryRsp(QW_FPARAMS(), qwMsg->msgType + 1, ctx, code, true));
|
QW_ERR_JRET(qwSendQueryRsp(QW_FPARAMS(), qwMsg->msgType + 1, ctx, code, true));
|
||||||
|
@ -794,16 +794,17 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql) {
|
||||||
taosEnableMemPoolUsage(ctx->memPoolSession);
|
taosEnableMemPoolUsage(ctx->memPoolSession);
|
||||||
code = qMsgToSubplan(qwMsg->msg, qwMsg->msgLen, &plan);
|
code = qMsgToSubplan(qwMsg->msg, qwMsg->msgLen, &plan);
|
||||||
taosDisableMemPoolUsage();
|
taosDisableMemPoolUsage();
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
QW_TASK_ELOG("task physical plan to subplan failed, code:%x - %s", code, tstrerror(code));
|
QW_TASK_ELOG("task physical plan to subplan failed, code:%x - %s", code, tstrerror(code));
|
||||||
QW_ERR_JRET(code);
|
QW_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosEnableMemPoolUsage(ctx->memPoolSession);
|
taosEnableMemPoolUsage(ctx->memPoolSession);
|
||||||
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, qwMsg->msgInfo.compressMsg, sql, OPTR_EXEC_MODEL_BATCH);
|
code = qCreateExecTask(qwMsg->node, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, qwMsg->msgInfo.compressMsg, sql,
|
||||||
|
OPTR_EXEC_MODEL_BATCH);
|
||||||
taosDisableMemPoolUsage();
|
taosDisableMemPoolUsage();
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code));
|
QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code));
|
||||||
qDestroyTask(pTaskInfo);
|
qDestroyTask(pTaskInfo);
|
||||||
|
@ -891,7 +892,7 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
atomic_store_8((int8_t *)&ctx->queryEnd, true);
|
atomic_store_8((int8_t *)&ctx->queryEnd, true);
|
||||||
atomic_store_8((int8_t *)&ctx->queryContinue, 0);
|
atomic_store_8((int8_t *)&ctx->queryContinue, 0);
|
||||||
if (!ctx->dynamicTask) {
|
if (!ctx->dynamicTask) {
|
||||||
qwFreeSinkHandle(ctx);
|
qwFreeSinkHandle(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -923,11 +924,11 @@ int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) {
|
||||||
qwMsg->connInfo = ctx->dataConnInfo;
|
qwMsg->connInfo = ctx->dataConnInfo;
|
||||||
code = qwBuildAndSendFetchRsp(ctx->fetchMsgType + 1, &qwMsg->connInfo, NULL, 0, code);
|
code = qwBuildAndSendFetchRsp(ctx->fetchMsgType + 1, &qwMsg->connInfo, NULL, 0, code);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
QW_TASK_ELOG("fetch rsp send fail, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code),
|
QW_TASK_ELOG("fetch rsp send fail, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code,
|
||||||
0);
|
tstrerror(code), 0);
|
||||||
} else {
|
} else {
|
||||||
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code, tstrerror(code),
|
QW_TASK_DLOG("fetch rsp send, handle:%p, code:%x - %s, dataLen:%d", qwMsg->connInfo.handle, code,
|
||||||
0);
|
tstrerror(code), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1032,8 +1033,8 @@ _return:
|
||||||
if (!rsped) {
|
if (!rsped) {
|
||||||
code = qwBuildAndSendFetchRsp(qwMsg->msgType + 1, &qwMsg->connInfo, rsp, dataLen, code);
|
code = qwBuildAndSendFetchRsp(qwMsg->msgType + 1, &qwMsg->connInfo, rsp, dataLen, code);
|
||||||
if (TSDB_CODE_SUCCESS != code) {
|
if (TSDB_CODE_SUCCESS != code) {
|
||||||
QW_TASK_ELOG("fetch rsp send fail, msgType:%s, handle:%p, code:%x - %s, dataLen:%d", TMSG_INFO(qwMsg->msgType + 1),
|
QW_TASK_ELOG("fetch rsp send fail, msgType:%s, handle:%p, code:%x - %s, dataLen:%d",
|
||||||
qwMsg->connInfo.handle, code, tstrerror(code), dataLen);
|
TMSG_INFO(qwMsg->msgType + 1), qwMsg->connInfo.handle, code, tstrerror(code), dataLen);
|
||||||
} else {
|
} else {
|
||||||
QW_TASK_DLOG("fetch rsp send, msgType:%s, handle:%p, code:%x - %s, dataLen:%d", TMSG_INFO(qwMsg->msgType + 1),
|
QW_TASK_DLOG("fetch rsp send, msgType:%s, handle:%p, code:%x - %s, dataLen:%d", TMSG_INFO(qwMsg->msgType + 1),
|
||||||
qwMsg->connInfo.handle, code, tstrerror(code), dataLen);
|
qwMsg->connInfo.handle, code, tstrerror(code), dataLen);
|
||||||
|
@ -1084,9 +1085,10 @@ _return:
|
||||||
if (code) {
|
if (code) {
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
QW_UPDATE_RSP_CODE(ctx, code);
|
QW_UPDATE_RSP_CODE(ctx, code);
|
||||||
(void)qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_FAIL, ctx->dynamicTask); // task already failed, no more error handling
|
(void)qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_FAIL,
|
||||||
|
ctx->dynamicTask); // task already failed, no more error handling
|
||||||
} else {
|
} else {
|
||||||
tmsgReleaseHandle(&qwMsg->connInfo, TAOS_CONN_SERVER);
|
tmsgReleaseHandle(&qwMsg->connInfo, TAOS_CONN_SERVER, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1096,7 +1098,7 @@ _return:
|
||||||
|
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
if (qwMsg->connInfo.handle != ctx->ctrlConnInfo.handle) {
|
if (qwMsg->connInfo.handle != ctx->ctrlConnInfo.handle) {
|
||||||
tmsgReleaseHandle(&qwMsg->connInfo, TAOS_CONN_SERVER);
|
tmsgReleaseHandle(&qwMsg->connInfo, TAOS_CONN_SERVER, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
qwReleaseTaskCtx(mgmt, ctx);
|
qwReleaseTaskCtx(mgmt, ctx);
|
||||||
|
@ -1138,7 +1140,8 @@ _return:
|
||||||
if (code) {
|
if (code) {
|
||||||
if (ctx) {
|
if (ctx) {
|
||||||
QW_UPDATE_RSP_CODE(ctx, code);
|
QW_UPDATE_RSP_CODE(ctx, code);
|
||||||
(void)qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_FAIL, ctx->dynamicTask); // task already failed, no more error handling
|
(void)qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_FAIL,
|
||||||
|
ctx->dynamicTask); // task already failed, no more error handling
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1170,7 +1173,7 @@ int32_t qwProcessHb(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *req) {
|
||||||
QW_LOCK(QW_WRITE, &sch->hbConnLock);
|
QW_LOCK(QW_WRITE, &sch->hbConnLock);
|
||||||
|
|
||||||
if (sch->hbConnInfo.handle) {
|
if (sch->hbConnInfo.handle) {
|
||||||
tmsgReleaseHandle(&sch->hbConnInfo, TAOS_CONN_SERVER);
|
tmsgReleaseHandle(&sch->hbConnInfo, TAOS_CONN_SERVER, 0);
|
||||||
sch->hbConnInfo.handle = NULL;
|
sch->hbConnInfo.handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1179,8 +1182,9 @@ int32_t qwProcessHb(SQWorker *mgmt, SQWMsg *qwMsg, SSchedulerHbReq *req) {
|
||||||
|
|
||||||
QW_UNLOCK(QW_WRITE, &sch->hbConnLock);
|
QW_UNLOCK(QW_WRITE, &sch->hbConnLock);
|
||||||
|
|
||||||
QW_DLOG("hb connection updated, clientId:%" PRIx64 ", nodeId:%d, fqdn:%s, port:%d, handle:%p, ahandle:%p", req->clientId,
|
QW_DLOG("hb connection updated, clientId:%" PRIx64 ", nodeId:%d, fqdn:%s, port:%d, handle:%p, ahandle:%p",
|
||||||
req->epId.nodeId, req->epId.ep.fqdn, req->epId.ep.port, qwMsg->connInfo.handle, qwMsg->connInfo.ahandle);
|
req->clientId, req->epId.nodeId, req->epId.ep.fqdn, req->epId.ep.port, qwMsg->connInfo.handle,
|
||||||
|
qwMsg->connInfo.ahandle);
|
||||||
|
|
||||||
qwReleaseScheduler(QW_READ, mgmt);
|
qwReleaseScheduler(QW_READ, mgmt);
|
||||||
|
|
||||||
|
@ -1190,7 +1194,7 @@ _return:
|
||||||
code = qwBuildAndSendHbRsp(&qwMsg->connInfo, &rsp, code);
|
code = qwBuildAndSendHbRsp(&qwMsg->connInfo, &rsp, code);
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
tmsgReleaseHandle(&qwMsg->connInfo, TAOS_CONN_SERVER);
|
tmsgReleaseHandle(&qwMsg->connInfo, TAOS_CONN_SERVER, 0);
|
||||||
qwMsg->connInfo.handle = NULL;
|
qwMsg->connInfo.handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1231,7 +1235,7 @@ void qwProcessHbTimerEvent(void *param, void *tmrId) {
|
||||||
if (taosTmrReset(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, param, mgmt->timer, &mgmt->hbTimer)) {
|
if (taosTmrReset(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, param, mgmt->timer, &mgmt->hbTimer)) {
|
||||||
qError("reset qworker hb timer error, timer stoppped");
|
qError("reset qworker hb timer error, timer stoppped");
|
||||||
}
|
}
|
||||||
(void)qwRelease(refId); // ignore error
|
(void)qwRelease(refId); // ignore error
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1245,7 +1249,7 @@ void qwProcessHbTimerEvent(void *param, void *tmrId) {
|
||||||
if (taosTmrReset(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, param, mgmt->timer, &mgmt->hbTimer)) {
|
if (taosTmrReset(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, param, mgmt->timer, &mgmt->hbTimer)) {
|
||||||
qError("reset qworker hb timer error, timer stoppped");
|
qError("reset qworker hb timer error, timer stoppped");
|
||||||
}
|
}
|
||||||
(void)qwRelease(refId); // ignore error
|
(void)qwRelease(refId); // ignore error
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1287,7 +1291,7 @@ _return:
|
||||||
QW_UNLOCK(QW_READ, &mgmt->schLock);
|
QW_UNLOCK(QW_READ, &mgmt->schLock);
|
||||||
|
|
||||||
for (int32_t j = 0; j < i; ++j) {
|
for (int32_t j = 0; j < i; ++j) {
|
||||||
(void)qwBuildAndSendHbRsp(&rspList[j].connInfo, &rspList[j].rsp, code); // ignore error
|
(void)qwBuildAndSendHbRsp(&rspList[j].connInfo, &rspList[j].rsp, code); // ignore error
|
||||||
/*QW_DLOG("hb rsp send, handle:%p, code:%x - %s, taskNum:%d", rspList[j].connInfo.handle, code, tstrerror(code),*/
|
/*QW_DLOG("hb rsp send, handle:%p, code:%x - %s, taskNum:%d", rspList[j].connInfo.handle, code, tstrerror(code),*/
|
||||||
/*(rspList[j].rsp.taskStatus ? (int32_t)taosArrayGetSize(rspList[j].rsp.taskStatus) : 0));*/
|
/*(rspList[j].rsp.taskStatus ? (int32_t)taosArrayGetSize(rspList[j].rsp.taskStatus) : 0));*/
|
||||||
tFreeSSchedulerHbRsp(&rspList[j].rsp);
|
tFreeSSchedulerHbRsp(&rspList[j].rsp);
|
||||||
|
@ -1304,7 +1308,7 @@ _return:
|
||||||
qError("reset qworker hb timer error, timer stoppped");
|
qError("reset qworker hb timer error, timer stoppped");
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)qwRelease(refId); // ignore error
|
(void)qwRelease(refId); // ignore error
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwProcessDelete(QW_FPARAMS_DEF, SQWMsg *qwMsg, SDeleteRes *pRes) {
|
int32_t qwProcessDelete(QW_FPARAMS_DEF, SQWMsg *qwMsg, SDeleteRes *pRes) {
|
||||||
|
@ -1361,7 +1365,7 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const S
|
||||||
qError("invalid param to init qworker");
|
qError("invalid param to init qworker");
|
||||||
QW_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
QW_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qwNum = atomic_add_fetch_32(&gQwMgmt.qwNum, 1);
|
int32_t qwNum = atomic_add_fetch_32(&gQwMgmt.qwNum, 1);
|
||||||
if (1 == qwNum) {
|
if (1 == qwNum) {
|
||||||
TAOS_MEMSET(gQwMgmt.param, 0, sizeof(gQwMgmt.param));
|
TAOS_MEMSET(gQwMgmt.param, 0, sizeof(gQwMgmt.param));
|
||||||
|
@ -1439,7 +1443,7 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const S
|
||||||
_return:
|
_return:
|
||||||
|
|
||||||
if (mgmt->refId >= 0) {
|
if (mgmt->refId >= 0) {
|
||||||
(void)qwRelease(mgmt->refId); // ignore error
|
(void)qwRelease(mgmt->refId); // ignore error
|
||||||
} else {
|
} else {
|
||||||
taosHashCleanup(mgmt->schHash);
|
taosHashCleanup(mgmt->schHash);
|
||||||
taosHashCleanup(mgmt->ctxHash);
|
taosHashCleanup(mgmt->ctxHash);
|
||||||
|
@ -1540,7 +1544,7 @@ int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64
|
||||||
if (NULL == rHandle.pMsgCb) {
|
if (NULL == rHandle.pMsgCb) {
|
||||||
QW_ERR_JRET(terrno);
|
QW_ERR_JRET(terrno);
|
||||||
}
|
}
|
||||||
|
|
||||||
rHandle.pMsgCb->clientRpc = qwMsg->connInfo.handle;
|
rHandle.pMsgCb->clientRpc = qwMsg->connInfo.handle;
|
||||||
rHandle.localExec = true;
|
rHandle.localExec = true;
|
||||||
|
|
||||||
|
@ -1611,7 +1615,7 @@ int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64
|
||||||
if (qComplete) {
|
if (qComplete) {
|
||||||
atomic_store_8((int8_t *)&ctx->queryEnd, true);
|
atomic_store_8((int8_t *)&ctx->queryEnd, true);
|
||||||
if (!ctx->dynamicTask) {
|
if (!ctx->dynamicTask) {
|
||||||
qwFreeSinkHandle(ctx);
|
qwFreeSinkHandle(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1629,24 +1633,25 @@ _return:
|
||||||
QW_RET(code);
|
QW_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void qWorkerRetireJob(uint64_t jobId, uint64_t clientId, int32_t errCode) {
|
void qWorkerRetireJob(uint64_t jobId, uint64_t clientId, int32_t errCode) {
|
||||||
char id[sizeof(jobId) + sizeof(clientId) + 1] = {0};
|
char id[sizeof(jobId) + sizeof(clientId) + 1] = {0};
|
||||||
QW_SET_QCID(id, jobId, clientId);
|
QW_SET_QCID(id, jobId, clientId);
|
||||||
|
|
||||||
SQWJobInfo* pJob = (SQWJobInfo*)taosHashGet(gQueryMgmt.pJobInfo, id, sizeof(id));
|
SQWJobInfo *pJob = (SQWJobInfo *)taosHashGet(gQueryMgmt.pJobInfo, id, sizeof(id));
|
||||||
if (NULL == pJob) {
|
if (NULL == pJob) {
|
||||||
qError("QID:0x%" PRIx64 " CID:0x%" PRIx64 " fail to get job from job hash", jobId, clientId);
|
qError("QID:0x%" PRIx64 " CID:0x%" PRIx64 " fail to get job from job hash", jobId, clientId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == atomic_val_compare_exchange_32(&pJob->errCode, 0, errCode) && 0 == atomic_val_compare_exchange_8(&pJob->retired, 0, 1)) {
|
if (0 == atomic_val_compare_exchange_32(&pJob->errCode, 0, errCode) &&
|
||||||
qDebug("QID:0x%" PRIx64 " CID:0x%" PRIx64 " mark retired, errCode: 0x%x, allocSize:%" PRId64,
|
0 == atomic_val_compare_exchange_8(&pJob->retired, 0, 1)) {
|
||||||
jobId, clientId, errCode, atomic_load_64(&pJob->memInfo->allocMemSize));
|
qDebug("QID:0x%" PRIx64 " CID:0x%" PRIx64 " mark retired, errCode: 0x%x, allocSize:%" PRId64, jobId, clientId,
|
||||||
|
errCode, atomic_load_64(&pJob->memInfo->allocMemSize));
|
||||||
|
|
||||||
(void)qwRetireJob(pJob);
|
(void)qwRetireJob(pJob);
|
||||||
} else {
|
} else {
|
||||||
qDebug("QID:0x%" PRIx64 " already retired, retired: %d, errCode: 0x%x, allocSize:%" PRId64, jobId, atomic_load_8(&pJob->retired), atomic_load_32(&pJob->errCode), atomic_load_64(&pJob->memInfo->allocMemSize));
|
qDebug("QID:0x%" PRIx64 " already retired, retired: %d, errCode: 0x%x, allocSize:%" PRId64, jobId,
|
||||||
|
atomic_load_8(&pJob->retired), atomic_load_32(&pJob->errCode), atomic_load_64(&pJob->memInfo->allocMemSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1666,7 +1671,8 @@ void qWorkerRetireJobs(int64_t retireSize, int32_t errCode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == atomic_val_compare_exchange_32(&pJob->errCode, 0, errCode) && 0 == atomic_val_compare_exchange_8(&pJob->retired, 0, 1)) {
|
if (0 == atomic_val_compare_exchange_32(&pJob->errCode, 0, errCode) &&
|
||||||
|
0 == atomic_val_compare_exchange_8(&pJob->retired, 0, 1)) {
|
||||||
int64_t aSize = atomic_load_64(&pJob->memInfo->allocMemSize);
|
int64_t aSize = atomic_load_64(&pJob->memInfo->allocMemSize);
|
||||||
bool retired = qwRetireJob(pJob);
|
bool retired = qwRetireJob(pJob);
|
||||||
|
|
||||||
|
@ -1680,7 +1686,7 @@ void qWorkerRetireJobs(int64_t retireSize, int32_t errCode) {
|
||||||
qDebug("QID:0x%" PRIx64 " CID:0x%" PRIx64 " job may already failed, errCode:%s", pJob->memInfo->jobId, pJob->memInfo->clientId, tstrerror(pJob->errCode));
|
qDebug("QID:0x%" PRIx64 " CID:0x%" PRIx64 " job may already failed, errCode:%s", pJob->memInfo->jobId, pJob->memInfo->clientId, tstrerror(pJob->errCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
pJob = (SQWJobInfo*)taosHashIterate(gQueryMgmt.pJobInfo, pJob);
|
pJob = (SQWJobInfo *)taosHashIterate(gQueryMgmt.pJobInfo, pJob);
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug("job retire in batch done, [prev:%d, curr:%d, total:%d] jobs, direct retiredSize:%" PRId64 " targetRetireSize:%" PRId64
|
qDebug("job retire in batch done, [prev:%d, curr:%d, total:%d] jobs, direct retiredSize:%" PRId64 " targetRetireSize:%" PRId64
|
||||||
|
@ -1689,5 +1695,3 @@ void qWorkerRetireJobs(int64_t retireSize, int32_t errCode) {
|
||||||
atomic_load_64(&gQueryMgmt.stat.taskInitNum),
|
atomic_load_64(&gQueryMgmt.stat.taskInitNum),
|
||||||
atomic_load_64(&gQueryMgmt.stat.taskExecDestroyNum), atomic_load_64(&gQueryMgmt.stat.taskSinkDestroyNum));
|
atomic_load_64(&gQueryMgmt.stat.taskExecDestroyNum), atomic_load_64(&gQueryMgmt.stat.taskSinkDestroyNum));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -509,7 +509,7 @@ int32_t schHandleDropCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
qDebug("QID:0x%" PRIx64 ",CID:0x%" PRIx64 ",TID:0x%" PRIx64 " drop task rsp received, code:0x%x", pParam->queryId,
|
qDebug("QID:0x%" PRIx64 ",CID:0x%" PRIx64 ",TID:0x%" PRIx64 " drop task rsp received, code:0x%x", pParam->queryId,
|
||||||
pParam->clientId, pParam->taskId, code);
|
pParam->clientId, pParam->taskId, code);
|
||||||
// called if drop task rsp received code
|
// called if drop task rsp received code
|
||||||
(void)rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT); // ignore error
|
(void)rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT, 0); // ignore error
|
||||||
|
|
||||||
if (pMsg->handle == NULL) {
|
if (pMsg->handle == NULL) {
|
||||||
qError("sch handle is NULL, may be already released and mem lea");
|
qError("sch handle is NULL, may be already released and mem lea");
|
||||||
|
@ -535,7 +535,7 @@ int32_t schHandleNotifyCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
|
|
||||||
int32_t schHandleLinkBrokenCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
int32_t schHandleLinkBrokenCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
SSchCallbackParamHeader *head = (SSchCallbackParamHeader *)param;
|
SSchCallbackParamHeader *head = (SSchCallbackParamHeader *)param;
|
||||||
(void)rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT); // ignore error
|
(void)rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT, 0); // ignore error
|
||||||
|
|
||||||
qDebug("handle %p is broken", pMsg->handle);
|
qDebug("handle %p is broken", pMsg->handle);
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ int32_t schHandleHbCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
|
|
||||||
if (code) {
|
if (code) {
|
||||||
qError("hb rsp error:%s", tstrerror(code));
|
qError("hb rsp error:%s", tstrerror(code));
|
||||||
(void)rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT); // ignore error
|
(void)rpcReleaseHandle(pMsg->handle, TAOS_CONN_CLIENT, 0); // ignore error
|
||||||
SCH_ERR_JRET(code);
|
SCH_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "tref.h"
|
#include "tref.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
|
||||||
FORCE_INLINE int32_t schAcquireJob(int64_t refId, SSchJob** ppJob) {
|
FORCE_INLINE int32_t schAcquireJob(int64_t refId, SSchJob **ppJob) {
|
||||||
qDebug("sch acquire jobId:0x%" PRIx64, refId);
|
qDebug("sch acquire jobId:0x%" PRIx64, refId);
|
||||||
*ppJob = (SSchJob *)taosAcquireRef(schMgmt.jobRef, refId);
|
*ppJob = (SSchJob *)taosAcquireRef(schMgmt.jobRef, refId);
|
||||||
if (NULL == *ppJob) {
|
if (NULL == *ppJob) {
|
||||||
|
@ -41,7 +41,7 @@ FORCE_INLINE int32_t schReleaseJob(int64_t refId) {
|
||||||
return taosReleaseRef(schMgmt.jobRef, refId);
|
return taosReleaseRef(schMgmt.jobRef, refId);
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE int32_t schReleaseJobEx(int64_t refId, int32_t* released) {
|
FORCE_INLINE int32_t schReleaseJobEx(int64_t refId, int32_t *released) {
|
||||||
if (0 == refId) {
|
if (0 == refId) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ FORCE_INLINE int32_t schReleaseJobEx(int64_t refId, int32_t* released) {
|
||||||
return taosReleaseRefEx(schMgmt.jobRef, refId, released);
|
return taosReleaseRefEx(schMgmt.jobRef, refId, released);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schDumpEpSet(SEpSet *pEpSet, char** ppRes) {
|
int32_t schDumpEpSet(SEpSet *pEpSet, char **ppRes) {
|
||||||
*ppRes = NULL;
|
*ppRes = NULL;
|
||||||
if (NULL == pEpSet) {
|
if (NULL == pEpSet) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -89,7 +89,7 @@ char *schGetOpStr(SCH_OP_TYPE type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void schFreeHbTrans(SSchHbTrans *pTrans) {
|
void schFreeHbTrans(SSchHbTrans *pTrans) {
|
||||||
(void)rpcReleaseHandle((void *)pTrans->trans.pHandleId, TAOS_CONN_CLIENT);
|
(void)rpcReleaseHandle((void *)pTrans->trans.pHandleId, TAOS_CONN_CLIENT, 0);
|
||||||
|
|
||||||
schFreeRpcCtx(&pTrans->rpcCtx);
|
schFreeRpcCtx(&pTrans->rpcCtx);
|
||||||
}
|
}
|
||||||
|
@ -202,11 +202,12 @@ void schDeregisterTaskHb(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
|
||||||
SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx);
|
SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx);
|
||||||
if (NULL == addr) {
|
if (NULL == addr) {
|
||||||
SCH_TASK_ELOG("fail to get the %dth condidateAddr in task, totalNum:%d", pTask->candidateIdx, (int32_t)taosArrayGetSize(pTask->candidateAddrs));
|
SCH_TASK_ELOG("fail to get the %dth condidateAddr in task, totalNum:%d", pTask->candidateIdx,
|
||||||
|
(int32_t)taosArrayGetSize(pTask->candidateAddrs));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryNodeEpId epId = {0};
|
SQueryNodeEpId epId = {0};
|
||||||
|
|
||||||
epId.nodeId = addr->nodeId;
|
epId.nodeId = addr->nodeId;
|
||||||
|
|
||||||
|
@ -240,11 +241,12 @@ int32_t schEnsureHbConnection(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
|
||||||
SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx);
|
SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx);
|
||||||
if (NULL == addr) {
|
if (NULL == addr) {
|
||||||
SCH_TASK_ELOG("fail to get the %dth condidateAddr in task, totalNum:%d", pTask->candidateIdx, (int32_t)taosArrayGetSize(pTask->candidateAddrs));
|
SCH_TASK_ELOG("fail to get the %dth condidateAddr in task, totalNum:%d", pTask->candidateIdx,
|
||||||
|
(int32_t)taosArrayGetSize(pTask->candidateAddrs));
|
||||||
return TSDB_CODE_SCH_INTERNAL_ERROR;
|
return TSDB_CODE_SCH_INTERNAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryNodeEpId epId = {0};
|
SQueryNodeEpId epId = {0};
|
||||||
|
|
||||||
epId.nodeId = addr->nodeId;
|
epId.nodeId = addr->nodeId;
|
||||||
|
|
||||||
|
@ -276,8 +278,8 @@ int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans) {
|
||||||
SCH_UNLOCK(SCH_WRITE, &hb->lock);
|
SCH_UNLOCK(SCH_WRITE, &hb->lock);
|
||||||
SCH_UNLOCK(SCH_READ, &schMgmt.hbLock);
|
SCH_UNLOCK(SCH_READ, &schMgmt.hbLock);
|
||||||
|
|
||||||
qDebug("hb connection updated, nodeId:%d, fqdn:%s, port:%d, pTrans:%p, pHandle:%p",
|
qDebug("hb connection updated, nodeId:%d, fqdn:%s, port:%d, pTrans:%p, pHandle:%p", epId->nodeId, epId->ep.fqdn,
|
||||||
epId->nodeId, epId->ep.fqdn, epId->ep.port, trans->pTrans, trans->pHandle);
|
epId->ep.port, trans->pTrans, trans->pHandle);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -323,7 +325,8 @@ uint64_t schGenUUID(void) {
|
||||||
uint64_t pid = taosGetPId();
|
uint64_t pid = taosGetPId();
|
||||||
int32_t val = atomic_add_fetch_32(&requestSerialId, 1);
|
int32_t val = atomic_add_fetch_32(&requestSerialId, 1);
|
||||||
|
|
||||||
uint64_t id = ((uint64_t)((hashId & 0x0FFF)) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF);
|
uint64_t id =
|
||||||
|
((uint64_t)((hashId & 0x0FFF)) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -373,17 +376,17 @@ void schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask)
|
||||||
*pTask = *task;
|
*pTask = *task;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schValidateSubplan(SSchJob *pJob, SSubplan* pSubplan, int32_t level, int32_t idx, int32_t taskNum) {
|
int32_t schValidateSubplan(SSchJob *pJob, SSubplan *pSubplan, int32_t level, int32_t idx, int32_t taskNum) {
|
||||||
if (NULL == pSubplan) {
|
if (NULL == pSubplan) {
|
||||||
SCH_JOB_ELOG("fail to get the %dth subplan, taskNum: %d, level: %d", idx, taskNum, level);
|
SCH_JOB_ELOG("fail to get the %dth subplan, taskNum: %d, level: %d", idx, taskNum, level);
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (QUERY_NODE_PHYSICAL_SUBPLAN != nodeType(pSubplan)) {
|
if (QUERY_NODE_PHYSICAL_SUBPLAN != nodeType(pSubplan)) {
|
||||||
SCH_JOB_ELOG("invalid subplan type, level:%d, subplanNodeType:%d", level, nodeType(pSubplan));
|
SCH_JOB_ELOG("invalid subplan type, level:%d, subplanNodeType:%d", level, nodeType(pSubplan));
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSubplan->subplanType < SUBPLAN_TYPE_MERGE || pSubplan->subplanType > SUBPLAN_TYPE_COMPUTE) {
|
if (pSubplan->subplanType < SUBPLAN_TYPE_MERGE || pSubplan->subplanType > SUBPLAN_TYPE_COMPUTE) {
|
||||||
SCH_JOB_ELOG("invalid subplanType %d, level:%d, subplan idx:%d", pSubplan->subplanType, level, idx);
|
SCH_JOB_ELOG("invalid subplanType %d, level:%d, subplan idx:%d", pSubplan->subplanType, level, idx);
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
@ -396,15 +399,17 @@ int32_t schValidateSubplan(SSchJob *pJob, SSubplan* pSubplan, int32_t level, int
|
||||||
|
|
||||||
if (SCH_IS_DATA_BIND_PLAN(pSubplan)) {
|
if (SCH_IS_DATA_BIND_PLAN(pSubplan)) {
|
||||||
if (pSubplan->execNode.epSet.numOfEps <= 0) {
|
if (pSubplan->execNode.epSet.numOfEps <= 0) {
|
||||||
SCH_JOB_ELOG("no execNode specifed for data src plan %d, numOfEps:%d", pSubplan->subplanType, pSubplan->execNode.epSet.numOfEps);
|
SCH_JOB_ELOG("no execNode specifed for data src plan %d, numOfEps:%d", pSubplan->subplanType,
|
||||||
|
pSubplan->execNode.epSet.numOfEps);
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_DATA_SRC_EP_MISS);
|
SCH_ERR_RET(TSDB_CODE_SCH_DATA_SRC_EP_MISS);
|
||||||
}
|
}
|
||||||
if (pSubplan->execNode.epSet.inUse >= pSubplan->execNode.epSet.numOfEps) {
|
if (pSubplan->execNode.epSet.inUse >= pSubplan->execNode.epSet.numOfEps) {
|
||||||
SCH_JOB_ELOG("invalid epset inUse %d for data src plan %d, numOfEps:%d", pSubplan->execNode.epSet.inUse, pSubplan->subplanType, pSubplan->execNode.epSet.numOfEps);
|
SCH_JOB_ELOG("invalid epset inUse %d for data src plan %d, numOfEps:%d", pSubplan->execNode.epSet.inUse,
|
||||||
|
pSubplan->subplanType, pSubplan->execNode.epSet.numOfEps);
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == pSubplan->pNode && pSubplan->subplanType != SUBPLAN_TYPE_MODIFY) {
|
if (NULL == pSubplan->pNode && pSubplan->subplanType != SUBPLAN_TYPE_MODIFY) {
|
||||||
SCH_JOB_ELOG("empty plan root node, level:%d, subplan idx:%d, subplanType:%d", level, idx, pSubplan->subplanType);
|
SCH_JOB_ELOG("empty plan root node, level:%d, subplan idx:%d, subplanType:%d", level, idx, pSubplan->subplanType);
|
||||||
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
|
@ -418,7 +423,7 @@ int32_t schValidateSubplan(SSchJob *pJob, SSubplan* pSubplan, int32_t level, int
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void schStopTaskDelayTimer(SSchJob *pJob, SSchTask* pTask, bool syncOp) {
|
void schStopTaskDelayTimer(SSchJob *pJob, SSchTask *pTask, bool syncOp) {
|
||||||
if (!taosTmrStopA(&pTask->delayTimer)) {
|
if (!taosTmrStopA(&pTask->delayTimer)) {
|
||||||
if (syncOp) {
|
if (syncOp) {
|
||||||
while (!taosTmrIsStopped(&pTask->delayTimer)) {
|
while (!taosTmrIsStopped(&pTask->delayTimer)) {
|
||||||
|
@ -429,5 +434,3 @@ void schStopTaskDelayTimer(SSchJob *pJob, SSchTask* pTask, bool syncOp) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -310,8 +310,8 @@ void transRefCliHandle(void* handle);
|
||||||
int32_t transUnrefCliHandle(void* handle);
|
int32_t transUnrefCliHandle(void* handle);
|
||||||
int32_t transGetRefCount(void* handle);
|
int32_t transGetRefCount(void* handle);
|
||||||
|
|
||||||
int32_t transReleaseCliHandle(void* handle);
|
int32_t transReleaseCliHandle(void* handle, int32_t status);
|
||||||
int32_t transReleaseSrvHandle(void* handle);
|
int32_t transReleaseSrvHandle(void* handle, int32_t status);
|
||||||
|
|
||||||
int32_t transSendRequest(void* pInit, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* pCtx);
|
int32_t transSendRequest(void* pInit, const SEpSet* pEpSet, STransMsg* pReq, STransCtx* pCtx);
|
||||||
int32_t transSendRecv(void* pInit, const SEpSet* pEpSet, STransMsg* pReq, STransMsg* pRsp);
|
int32_t transSendRecv(void* pInit, const SEpSet* pEpSet, STransMsg* pReq, STransMsg* pRsp);
|
||||||
|
|
|
@ -69,7 +69,9 @@ void tmsgSendRsp(SRpcMsg* pMsg) {
|
||||||
|
|
||||||
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg) { (*defaultMsgCb.registerBrokenLinkArgFp)(pMsg); }
|
void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg) { (*defaultMsgCb.registerBrokenLinkArgFp)(pMsg); }
|
||||||
|
|
||||||
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type) { (*defaultMsgCb.releaseHandleFp)(pHandle, type); }
|
void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type, int32_t status) {
|
||||||
|
(*defaultMsgCb.releaseHandleFp)(pHandle, type, status);
|
||||||
|
}
|
||||||
|
|
||||||
void tmsgReportStartup(const char* name, const char* desc) { (*defaultMsgCb.reportStartupFp)(name, desc); }
|
void tmsgReportStartup(const char* name, const char* desc) { (*defaultMsgCb.reportStartupFp)(name, desc); }
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ void (*taosCloseHandle[])(void* arg) = {transCloseServer, transCloseClient};
|
||||||
void (*taosRefHandle[])(void* handle) = {transRefSrvHandle, transRefCliHandle};
|
void (*taosRefHandle[])(void* handle) = {transRefSrvHandle, transRefCliHandle};
|
||||||
void (*taosUnRefHandle[])(void* handle) = {transUnrefSrvHandle, NULL};
|
void (*taosUnRefHandle[])(void* handle) = {transUnrefSrvHandle, NULL};
|
||||||
|
|
||||||
int (*transReleaseHandle[])(void* handle) = {transReleaseSrvHandle, transReleaseCliHandle};
|
int (*transReleaseHandle[])(void* handle, int32_t status) = {transReleaseSrvHandle, transReleaseCliHandle};
|
||||||
|
|
||||||
static int32_t transValidLocalFqdn(const char* localFqdn, uint32_t* ip) {
|
static int32_t transValidLocalFqdn(const char* localFqdn, uint32_t* ip) {
|
||||||
int32_t code = taosGetIpv4FromFqdn(localFqdn, ip);
|
int32_t code = taosGetIpv4FromFqdn(localFqdn, ip);
|
||||||
|
@ -217,7 +217,9 @@ void rpcRefHandle(void* handle, int8_t type) { (*taosRefHandle[type])(handle); }
|
||||||
void rpcUnrefHandle(void* handle, int8_t type) { (*taosUnRefHandle[type])(handle); }
|
void rpcUnrefHandle(void* handle, int8_t type) { (*taosUnRefHandle[type])(handle); }
|
||||||
|
|
||||||
int32_t rpcRegisterBrokenLinkArg(SRpcMsg* msg) { return transRegisterMsg(msg); }
|
int32_t rpcRegisterBrokenLinkArg(SRpcMsg* msg) { return transRegisterMsg(msg); }
|
||||||
int32_t rpcReleaseHandle(void* handle, int8_t type) { return (*transReleaseHandle[type])(handle); }
|
int32_t rpcReleaseHandle(void* handle, int8_t type, int32_t status) {
|
||||||
|
return (*transReleaseHandle[type])(handle, status);
|
||||||
|
}
|
||||||
|
|
||||||
// client only
|
// client only
|
||||||
int32_t rpcSetDefaultAddr(void* thandle, const char* ip, const char* fqdn) {
|
int32_t rpcSetDefaultAddr(void* thandle, const char* ip, const char* fqdn) {
|
||||||
|
|
|
@ -555,9 +555,39 @@ int32_t cliBuildRespFromCont(SCliReq* pReq, STransMsg* pResp, STransMsgHead* pHe
|
||||||
pResp->info.handle = (void*)qid;
|
pResp->info.handle = (void*)qid;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int8_t cliMayNotifyUserOnRecvReleaseExcept(SCliConn* conn, STransMsgHead* pHead, SCliReq* pReq) {
|
||||||
|
int32_t code = 0;
|
||||||
|
if (pHead->code == 0 || pHead->msgType != TDMT_SCH_TASK_RELEASE) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// no ahandle, no need to notify user
|
||||||
|
if (pReq == NULL || pReq->ctx == NULL || pReq->ctx->ahandle == NULL) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCliThrd* pThrd = conn->hostThrd;
|
||||||
|
STransMsg resp = {.code = pHead->code};
|
||||||
|
int64_t qId = taosHton64(pHead->qid);
|
||||||
|
STraceId* trace = &pHead->traceId;
|
||||||
|
code = cliBuildExceptResp(pThrd, pReq, &resp);
|
||||||
|
if (code != 0) {
|
||||||
|
tGWarn("%s conn %p failed to build except resp for req:%" PRId64 " since %s", CONN_GET_INST_LABEL(conn), conn, qId,
|
||||||
|
tstrerror(code));
|
||||||
|
}
|
||||||
|
code = cliNotifyCb(conn, NULL, &resp);
|
||||||
|
if (code != 0) {
|
||||||
|
tGWarn("%s conn %p failed to notify user for req:%" PRId64 " since %s", CONN_GET_INST_LABEL(conn), conn, qId,
|
||||||
|
tstrerror(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyReq(pReq);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
int32_t cliHandleState_mayHandleReleaseResp(SCliConn* conn, STransMsgHead* pHead) {
|
int32_t cliHandleState_mayHandleReleaseResp(SCliConn* conn, STransMsgHead* pHead) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCliThrd* pThrd = conn->hostThrd;
|
SCliThrd* pThrd = conn->hostThrd;
|
||||||
|
int8_t notifyUser = 0;
|
||||||
if (pHead->msgType == TDMT_SCH_TASK_RELEASE || pHead->msgType == TDMT_SCH_TASK_RELEASE + 1) {
|
if (pHead->msgType == TDMT_SCH_TASK_RELEASE || pHead->msgType == TDMT_SCH_TASK_RELEASE + 1) {
|
||||||
int64_t qId = taosHton64(pHead->qid);
|
int64_t qId = taosHton64(pHead->qid);
|
||||||
STraceId* trace = &pHead->traceId;
|
STraceId* trace = &pHead->traceId;
|
||||||
|
@ -597,7 +627,11 @@ int32_t cliHandleState_mayHandleReleaseResp(SCliConn* conn, STransMsgHead* pHead
|
||||||
removeReqFromSendQ(pReq);
|
removeReqFromSendQ(pReq);
|
||||||
STraceId* trace = &pReq->msg.info.traceId;
|
STraceId* trace = &pReq->msg.info.traceId;
|
||||||
tGDebug("start to free msg %p", pReq);
|
tGDebug("start to free msg %p", pReq);
|
||||||
destroyReqWrapper(pReq, pThrd);
|
|
||||||
|
if (cliMayNotifyUserOnRecvReleaseExcept(conn, pHead, pReq)) {
|
||||||
|
} else {
|
||||||
|
destroyReqWrapper(pReq, pThrd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
taosMemoryFree(pHead);
|
taosMemoryFree(pHead);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -1259,7 +1293,8 @@ static void cliHandleException(SCliConn* conn) {
|
||||||
if (conn->registered) {
|
if (conn->registered) {
|
||||||
int8_t ref = transGetRefCount(conn);
|
int8_t ref = transGetRefCount(conn);
|
||||||
if (ref == 0 && !uv_is_closing((uv_handle_t*)conn->stream)) {
|
if (ref == 0 && !uv_is_closing((uv_handle_t*)conn->stream)) {
|
||||||
tTrace("%s conn %p fd %d,%d,%d,%p uv_closed", CONN_GET_INST_LABEL(conn), conn, conn->stream->u.fd, conn->stream->io_watcher.fd, conn->stream->accepted_fd, conn->stream->queued_fds);
|
tTrace("%s conn %p fd %d,%d,%d,%p uv_closed", CONN_GET_INST_LABEL(conn), conn, conn->stream->u.fd,
|
||||||
|
conn->stream->io_watcher.fd, conn->stream->accepted_fd, conn->stream->queued_fds);
|
||||||
uv_close((uv_handle_t*)conn->stream, cliDestroy);
|
uv_close((uv_handle_t*)conn->stream, cliDestroy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1785,9 +1820,7 @@ FORCE_INLINE int32_t cliBuildExceptResp(SCliThrd* pThrd, SCliReq* pReq, STransMs
|
||||||
|
|
||||||
STrans* pInst = pThrd->pInst;
|
STrans* pInst = pThrd->pInst;
|
||||||
|
|
||||||
SReqCtx* pCtx = pReq ? pReq->ctx : NULL;
|
SReqCtx* pCtx = pReq ? pReq->ctx : NULL;
|
||||||
STransMsg resp = {0};
|
|
||||||
// resp.code = (conn->connnected ? TSDB_CODE_RPC_BROKEN_LINK : TSDB_CODE_RPC_NETWORK_UNAVAIL);
|
|
||||||
pResp->msgType = pReq ? pReq->msg.msgType + 1 : 0;
|
pResp->msgType = pReq ? pReq->msg.msgType + 1 : 0;
|
||||||
pResp->info.cliVer = pInst->compatibilityVer;
|
pResp->info.cliVer = pInst->compatibilityVer;
|
||||||
pResp->info.ahandle = pCtx ? pCtx->ahandle : 0;
|
pResp->info.ahandle = pCtx ? pCtx->ahandle : 0;
|
||||||
|
@ -3103,15 +3136,18 @@ SCliThrd* transGetWorkThrd(STrans* trans, int64_t handle) {
|
||||||
SCliThrd* pThrd = transGetWorkThrdFromHandle(trans, handle);
|
SCliThrd* pThrd = transGetWorkThrdFromHandle(trans, handle);
|
||||||
return pThrd;
|
return pThrd;
|
||||||
}
|
}
|
||||||
int32_t transReleaseCliHandle(void* handle) {
|
int32_t transReleaseCliHandle(void* handle, int32_t status) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SCliThrd* pThrd = transGetWorkThrdFromHandle(NULL, (int64_t)handle);
|
SCliThrd* pThrd = transGetWorkThrdFromHandle(NULL, (int64_t)handle);
|
||||||
if (pThrd == NULL) {
|
if (pThrd == NULL) {
|
||||||
return TSDB_CODE_RPC_BROKEN_LINK;
|
return TSDB_CODE_RPC_BROKEN_LINK;
|
||||||
}
|
}
|
||||||
|
|
||||||
STransMsg tmsg = {
|
STransMsg tmsg = {.msgType = TDMT_SCH_TASK_RELEASE,
|
||||||
.msgType = TDMT_SCH_TASK_RELEASE, .info.handle = handle, .info.ahandle = (void*)0, .info.qId = (int64_t)handle};
|
.info.handle = handle,
|
||||||
|
.info.ahandle = (void*)0,
|
||||||
|
.info.qId = (int64_t)handle,
|
||||||
|
code = status};
|
||||||
|
|
||||||
TRACE_SET_MSGID(&tmsg.info.traceId, tGenIdPI64());
|
TRACE_SET_MSGID(&tmsg.info.traceId, tGenIdPI64());
|
||||||
|
|
||||||
|
|
|
@ -1858,7 +1858,7 @@ void transUnrefSrvHandle(void* handle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t transReleaseSrvHandle(void* handle) {
|
int32_t transReleaseSrvHandle(void* handle, int32_t status) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SRpcHandleInfo* info = handle;
|
SRpcHandleInfo* info = handle;
|
||||||
SExHandle* exh = info->handle;
|
SExHandle* exh = info->handle;
|
||||||
|
@ -1871,7 +1871,7 @@ int32_t transReleaseSrvHandle(void* handle) {
|
||||||
ASYNC_ERR_JRET(pThrd);
|
ASYNC_ERR_JRET(pThrd);
|
||||||
|
|
||||||
STransMsg tmsg = {.msgType = TDMT_SCH_TASK_RELEASE,
|
STransMsg tmsg = {.msgType = TDMT_SCH_TASK_RELEASE,
|
||||||
.code = 0,
|
.code = status,
|
||||||
.info.handle = exh,
|
.info.handle = exh,
|
||||||
.info.ahandle = NULL,
|
.info.ahandle = NULL,
|
||||||
.info.refId = refId,
|
.info.refId = refId,
|
||||||
|
|
|
@ -96,7 +96,7 @@ class Client {
|
||||||
}
|
}
|
||||||
void SendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) {
|
void SendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) {
|
||||||
if (req->info.handle != NULL) {
|
if (req->info.handle != NULL) {
|
||||||
rpcReleaseHandle(req->info.handle, TAOS_CONN_CLIENT);
|
rpcReleaseHandle(req->info.handle, TAOS_CONN_CLIENT, 0);
|
||||||
req->info.handle = NULL;
|
req->info.handle = NULL;
|
||||||
}
|
}
|
||||||
SendAndRecv(req, resp);
|
SendAndRecv(req, resp);
|
||||||
|
@ -191,7 +191,7 @@ static void processReleaseHandleCb(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet)
|
||||||
rpcMsg.code = 0;
|
rpcMsg.code = 0;
|
||||||
rpcSendResponse(&rpcMsg);
|
rpcSendResponse(&rpcMsg);
|
||||||
|
|
||||||
rpcReleaseHandle(&pMsg->info, TAOS_CONN_SERVER);
|
rpcReleaseHandle(&pMsg->info, TAOS_CONN_SERVER, 0);
|
||||||
}
|
}
|
||||||
static void processRegisterFailure(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
static void processRegisterFailure(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
{
|
{
|
||||||
|
@ -366,7 +366,7 @@ TEST_F(TransEnv, cliPersistHandle) {
|
||||||
//}
|
//}
|
||||||
handle = resp.info.handle;
|
handle = resp.info.handle;
|
||||||
}
|
}
|
||||||
rpcReleaseHandle(handle, TAOS_CONN_CLIENT);
|
rpcReleaseHandle(handle, TAOS_CONN_CLIENT, 0);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
SRpcMsg req = {0};
|
SRpcMsg req = {0};
|
||||||
req.msgType = 1;
|
req.msgType = 1;
|
||||||
|
|
|
@ -106,7 +106,7 @@ class Client {
|
||||||
}
|
}
|
||||||
void SendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) {
|
void SendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) {
|
||||||
if (req->info.handle != NULL) {
|
if (req->info.handle != NULL) {
|
||||||
rpcReleaseHandle(req->info.handle, TAOS_CONN_CLIENT);
|
rpcReleaseHandle(req->info.handle, TAOS_CONN_CLIENT, 0);
|
||||||
req->info.handle = NULL;
|
req->info.handle = NULL;
|
||||||
}
|
}
|
||||||
SendAndRecv(req, resp);
|
SendAndRecv(req, resp);
|
||||||
|
@ -201,7 +201,7 @@ static void processReleaseHandleCb(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet)
|
||||||
rpcMsg.code = 0;
|
rpcMsg.code = 0;
|
||||||
rpcSendResponse(&rpcMsg);
|
rpcSendResponse(&rpcMsg);
|
||||||
|
|
||||||
rpcReleaseHandle(&pMsg->info, TAOS_CONN_SERVER);
|
rpcReleaseHandle(&pMsg->info, TAOS_CONN_SERVER, 0);
|
||||||
}
|
}
|
||||||
static void processRegisterFailure(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
static void processRegisterFailure(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
|
||||||
// {
|
// {
|
||||||
|
|
Loading…
Reference in New Issue