fix serialize
This commit is contained in:
parent
ec97115b83
commit
d02850382c
|
@ -165,7 +165,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
// }
|
// }
|
||||||
break;
|
break;
|
||||||
case TDMT_VND_SUBMIT:
|
case TDMT_VND_SUBMIT:
|
||||||
printf("vnode %d write data %ld\n", pVnode->vgId, ver);
|
/*printf("vnode %d write data %ld\n", pVnode->vgId, ver);*/
|
||||||
if (pVnode->config.streamMode == 0) {
|
if (pVnode->config.streamMode == 0) {
|
||||||
if (tsdbInsertData(pVnode->pTsdb, (SSubmitReq *)ptr, NULL) < 0) {
|
if (tsdbInsertData(pVnode->pTsdb, (SSubmitReq *)ptr, NULL) < 0) {
|
||||||
// TODO: handle error
|
// TODO: handle error
|
||||||
|
|
|
@ -86,7 +86,7 @@ void schFreeRpcCtx(SRpcCtx *pCtx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void schFreeTask(SSchTask* pTask) {
|
void schFreeTask(SSchTask *pTask) {
|
||||||
if (pTask->candidateAddrs) {
|
if (pTask->candidateAddrs) {
|
||||||
taosArrayDestroy(pTask->candidateAddrs);
|
taosArrayDestroy(pTask->candidateAddrs);
|
||||||
}
|
}
|
||||||
|
@ -125,12 +125,14 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m
|
||||||
case TDMT_SCH_LINK_BROKEN:
|
case TDMT_SCH_LINK_BROKEN:
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
case TDMT_VND_QUERY_RSP: // query_rsp may be processed later than ready_rsp
|
case TDMT_VND_QUERY_RSP: // query_rsp may be processed later than ready_rsp
|
||||||
if (lastMsgType != reqMsgType && -1 != lastMsgType && TDMT_VND_FETCH != lastMsgType) {
|
if (lastMsgType != reqMsgType && -1 != lastMsgType && TDMT_VND_FETCH != lastMsgType) {
|
||||||
SCH_TASK_DLOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), TMSG_INFO(msgType));
|
SCH_TASK_DLOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType),
|
||||||
|
TMSG_INFO(msgType));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
||||||
SCH_TASK_DLOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType));
|
SCH_TASK_DLOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus),
|
||||||
|
TMSG_INFO(msgType));
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_SET_TASK_LASTMSG_TYPE(pTask, -1);
|
SCH_SET_TASK_LASTMSG_TYPE(pTask, -1);
|
||||||
|
@ -138,25 +140,29 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m
|
||||||
case TDMT_VND_RES_READY_RSP:
|
case TDMT_VND_RES_READY_RSP:
|
||||||
reqMsgType = TDMT_VND_QUERY;
|
reqMsgType = TDMT_VND_QUERY;
|
||||||
if (lastMsgType != reqMsgType && -1 != lastMsgType) {
|
if (lastMsgType != reqMsgType && -1 != lastMsgType) {
|
||||||
SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", (lastMsgType > 0 ? TMSG_INFO(lastMsgType) : "null"), TMSG_INFO(msgType));
|
SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s",
|
||||||
|
(lastMsgType > 0 ? TMSG_INFO(lastMsgType) : "null"), TMSG_INFO(msgType));
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
||||||
SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType));
|
SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus),
|
||||||
|
TMSG_INFO(msgType));
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_SET_TASK_LASTMSG_TYPE(pTask, -1);
|
SCH_SET_TASK_LASTMSG_TYPE(pTask, -1);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
case TDMT_VND_FETCH_RSP:
|
case TDMT_VND_FETCH_RSP:
|
||||||
if (lastMsgType != reqMsgType && -1 != lastMsgType) {
|
if (lastMsgType != reqMsgType && -1 != lastMsgType) {
|
||||||
SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), TMSG_INFO(msgType));
|
SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType),
|
||||||
|
TMSG_INFO(msgType));
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
||||||
SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType));
|
SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus),
|
||||||
|
TMSG_INFO(msgType));
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,12 +177,14 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastMsgType != reqMsgType) {
|
if (lastMsgType != reqMsgType) {
|
||||||
SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), TMSG_INFO(msgType));
|
SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType),
|
||||||
|
TMSG_INFO(msgType));
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
if (taskStatus != JOB_TASK_STATUS_EXECUTING && taskStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED) {
|
||||||
SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType));
|
SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus),
|
||||||
|
TMSG_INFO(msgType));
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +662,8 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
||||||
if (SCH_IS_DATA_SRC_TASK(pTask)) {
|
if (SCH_IS_DATA_SRC_TASK(pTask)) {
|
||||||
if (pTask->tryTimes >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
|
if (pTask->tryTimes >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
|
||||||
*needRetry = false;
|
*needRetry = false;
|
||||||
SCH_TASK_DLOG("task no more retry since all ep tried, tryTimes:%d, epNum:%d", pTask->tryTimes, SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode));
|
SCH_TASK_DLOG("task no more retry since all ep tried, tryTimes:%d, epNum:%d", pTask->tryTimes,
|
||||||
|
SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode));
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -662,7 +671,8 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
||||||
|
|
||||||
if ((pTask->candidateIdx + 1) >= candidateNum) {
|
if ((pTask->candidateIdx + 1) >= candidateNum) {
|
||||||
*needRetry = false;
|
*needRetry = false;
|
||||||
SCH_TASK_DLOG("task no more retry since all candiates tried, candidateIdx:%d, candidateNum:%d", pTask->candidateIdx, candidateNum);
|
SCH_TASK_DLOG("task no more retry since all candiates tried, candidateIdx:%d, candidateNum:%d",
|
||||||
|
pTask->candidateIdx, candidateNum);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -706,9 +716,8 @@ int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans) {
|
||||||
memcpy(&hb->trans, trans, sizeof(*trans));
|
memcpy(&hb->trans, trans, sizeof(*trans));
|
||||||
SCH_UNLOCK(SCH_WRITE, &hb->lock);
|
SCH_UNLOCK(SCH_WRITE, &hb->lock);
|
||||||
|
|
||||||
qDebug("hb connection updated, sId:%" PRIx64 ", nodeId:%d, fqdn:%s, port:%d, instance:%p, handle:%p",
|
qDebug("hb connection updated, sId:%" PRIx64 ", nodeId:%d, fqdn:%s, port:%d, instance:%p, handle:%p", schMgmt.sId,
|
||||||
schMgmt.sId, epId->nodeId, epId->ep.fqdn, epId->ep.port, trans->transInst,
|
epId->nodeId, epId->ep.fqdn, epId->ep.port, trans->transInst, trans->transHandle);
|
||||||
trans->transHandle);
|
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -965,7 +974,8 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
int8_t status = 0;
|
int8_t status = 0;
|
||||||
|
|
||||||
if (schJobNeedToStop(pJob, &status)) {
|
if (schJobNeedToStop(pJob, &status)) {
|
||||||
SCH_TASK_ELOG("rsp not processed cause of job status, job status:%s, rspCode:0x%x", jobTaskStatusStr(status), rspCode);
|
SCH_TASK_ELOG("rsp not processed cause of job status, job status:%s, rspCode:0x%x", jobTaskStatusStr(status),
|
||||||
|
rspCode);
|
||||||
SCH_RET(atomic_load_32(&pJob->errCode));
|
SCH_RET(atomic_load_32(&pJob->errCode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1011,21 +1021,21 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_QUERY_RSP: {
|
case TDMT_VND_QUERY_RSP: {
|
||||||
SQueryTableRsp rsp = {0};
|
SQueryTableRsp rsp = {0};
|
||||||
if (msg) {
|
if (msg) {
|
||||||
tDeserializeSQueryTableRsp(msg, msgSize, &rsp);
|
tDeserializeSQueryTableRsp(msg, msgSize, &rsp);
|
||||||
SCH_ERR_JRET(rsp.code);
|
SCH_ERR_JRET(rsp.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_ERR_JRET(rspCode);
|
SCH_ERR_JRET(rspCode);
|
||||||
|
|
||||||
if (NULL == msg) {
|
if (NULL == msg) {
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
//SCH_ERR_JRET(schBuildAndSendMsg(pJob, pTask, NULL, TDMT_VND_RES_READY));
|
// SCH_ERR_JRET(schBuildAndSendMsg(pJob, pTask, NULL, TDMT_VND_RES_READY));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TDMT_VND_RES_READY_RSP: {
|
case TDMT_VND_RES_READY_RSP: {
|
||||||
SResReadyRsp *rsp = (SResReadyRsp *)msg;
|
SResReadyRsp *rsp = (SResReadyRsp *)msg;
|
||||||
|
@ -1088,14 +1098,14 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode) {
|
int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param;
|
||||||
SSchTask *pTask = NULL;
|
SSchTask *pTask = NULL;
|
||||||
|
|
||||||
SSchJob *pJob = schAcquireJob(pParam->refId);
|
SSchJob *pJob = schAcquireJob(pParam->refId);
|
||||||
if (NULL == pJob) {
|
if (NULL == pJob) {
|
||||||
qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 "taosAcquireRef job failed, may be dropped, refId:%" PRIx64,
|
qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 "taosAcquireRef job failed, may be dropped, refId:%" PRIx64,
|
||||||
pParam->queryId, pParam->taskId, pParam->refId);
|
pParam->queryId, pParam->taskId, pParam->refId);
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_JOB_FREED);
|
SCH_ERR_JRET(TSDB_CODE_QRY_JOB_FREED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1173,7 +1183,8 @@ int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
||||||
SCH_ERR_RET(schUpdateHbConnection(&rsp.epId, &trans));
|
SCH_ERR_RET(schUpdateHbConnection(&rsp.epId, &trans));
|
||||||
|
|
||||||
int32_t taskNum = (int32_t)taosArrayGetSize(rsp.taskStatus);
|
int32_t taskNum = (int32_t)taosArrayGetSize(rsp.taskStatus);
|
||||||
qDebug("%d task status in hb rsp, nodeId:%d, fqdn:%s, port:%d", taskNum, rsp.epId.nodeId, rsp.epId.ep.fqdn, rsp.epId.ep.port);
|
qDebug("%d task status in hb rsp, nodeId:%d, fqdn:%s, port:%d", taskNum, rsp.epId.nodeId, rsp.epId.ep.fqdn,
|
||||||
|
rsp.epId.ep.port);
|
||||||
|
|
||||||
for (int32_t i = 0; i < taskNum; ++i) {
|
for (int32_t i = 0; i < taskNum; ++i) {
|
||||||
STaskStatus *taskStatus = taosArrayGet(rsp.taskStatus, i);
|
STaskStatus *taskStatus = taosArrayGet(rsp.taskStatus, i);
|
||||||
|
@ -1188,7 +1199,8 @@ int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) {
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
SCH_JOB_DLOG("TID:0x%" PRIx64 " task status in server: %s", taskStatus->taskId, jobTaskStatusStr(taskStatus->status));
|
SCH_JOB_DLOG("TID:0x%" PRIx64 " task status in server: %s", taskStatus->taskId,
|
||||||
|
jobTaskStatusStr(taskStatus->status));
|
||||||
|
|
||||||
schReleaseJob(taskStatus->refId);
|
schReleaseJob(taskStatus->refId);
|
||||||
}
|
}
|
||||||
|
@ -1208,7 +1220,7 @@ int32_t schHandleLinkBrokenCallback(void *param, const SDataBuf *pMsg, int32_t c
|
||||||
|
|
||||||
if (head->isHbParam) {
|
if (head->isHbParam) {
|
||||||
SSchHbCallbackParam *hbParam = (SSchHbCallbackParam *)param;
|
SSchHbCallbackParam *hbParam = (SSchHbCallbackParam *)param;
|
||||||
SSchTrans trans = {.transInst = hbParam->transport, .transHandle = NULL};
|
SSchTrans trans = {.transInst = hbParam->transport, .transHandle = NULL};
|
||||||
SCH_ERR_RET(schUpdateHbConnection(&hbParam->nodeEpId, &trans));
|
SCH_ERR_RET(schUpdateHbConnection(&hbParam->nodeEpId, &trans));
|
||||||
|
|
||||||
SCH_ERR_RET(schBuildAndSendHbMsg(&hbParam->nodeEpId));
|
SCH_ERR_RET(schBuildAndSendHbMsg(&hbParam->nodeEpId));
|
||||||
|
@ -1219,7 +1231,6 @@ int32_t schHandleLinkBrokenCallback(void *param, const SDataBuf *pMsg, int32_t c
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) {
|
int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) {
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case TDMT_VND_CREATE_TABLE:
|
case TDMT_VND_CREATE_TABLE:
|
||||||
|
@ -1259,7 +1270,7 @@ void schFreeRpcCtxVal(const void *arg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMsgSendInfo* pMsgSendInfo = (SMsgSendInfo *)arg;
|
SMsgSendInfo *pMsgSendInfo = (SMsgSendInfo *)arg;
|
||||||
taosMemoryFreeClear(pMsgSendInfo->param);
|
taosMemoryFreeClear(pMsgSendInfo->param);
|
||||||
taosMemoryFreeClear(pMsgSendInfo);
|
taosMemoryFreeClear(pMsgSendInfo);
|
||||||
}
|
}
|
||||||
|
@ -1301,10 +1312,9 @@ int32_t schMakeHbCallbackParam(SSchJob *pJob, SSchTask *pTask, void **pParam) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *brokenVal, bool isHb) {
|
int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *brokenVal, bool isHb) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SMsgSendInfo* pMsgSendInfo = NULL;
|
SMsgSendInfo *pMsgSendInfo = NULL;
|
||||||
|
|
||||||
pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||||
if (NULL == pMsgSendInfo) {
|
if (NULL == pMsgSendInfo) {
|
||||||
|
@ -1318,7 +1328,7 @@ int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *
|
||||||
SCH_ERR_JRET(schMakeTaskCallbackParam(pJob, pTask, &pMsgSendInfo->param));
|
SCH_ERR_JRET(schMakeTaskCallbackParam(pJob, pTask, &pMsgSendInfo->param));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t msgType = TDMT_SCH_LINK_BROKEN;
|
int32_t msgType = TDMT_SCH_LINK_BROKEN;
|
||||||
__async_send_cb_fn_t fp = NULL;
|
__async_send_cb_fn_t fp = NULL;
|
||||||
SCH_ERR_JRET(schGetCallbackFp(msgType, &fp));
|
SCH_ERR_JRET(schGetCallbackFp(msgType, &fp));
|
||||||
|
|
||||||
|
@ -1340,9 +1350,9 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
|
int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSchTaskCallbackParam *param = NULL;
|
SSchTaskCallbackParam *param = NULL;
|
||||||
SMsgSendInfo* pMsgSendInfo = NULL;
|
SMsgSendInfo *pMsgSendInfo = NULL;
|
||||||
|
|
||||||
pCtx->args = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK);
|
pCtx->args = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK);
|
||||||
if (NULL == pCtx->args) {
|
if (NULL == pCtx->args) {
|
||||||
|
@ -1362,7 +1372,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t msgType = TDMT_VND_RES_READY_RSP;
|
int32_t msgType = TDMT_VND_RES_READY_RSP;
|
||||||
__async_send_cb_fn_t fp = NULL;
|
__async_send_cb_fn_t fp = NULL;
|
||||||
SCH_ERR_JRET(schGetCallbackFp(TDMT_VND_RES_READY, &fp));
|
SCH_ERR_JRET(schGetCallbackFp(TDMT_VND_RES_READY, &fp));
|
||||||
|
|
||||||
|
@ -1394,11 +1404,11 @@ _return:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
|
int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSchHbCallbackParam *param = NULL;
|
SSchHbCallbackParam *param = NULL;
|
||||||
SMsgSendInfo* pMsgSendInfo = NULL;
|
SMsgSendInfo *pMsgSendInfo = NULL;
|
||||||
SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx);
|
SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx);
|
||||||
SQueryNodeEpId epId = {0};
|
SQueryNodeEpId epId = {0};
|
||||||
|
|
||||||
epId.nodeId = addr->nodeId;
|
epId.nodeId = addr->nodeId;
|
||||||
memcpy(&epId.ep, SCH_GET_CUR_EP(addr), sizeof(SEp));
|
memcpy(&epId.ep, SCH_GET_CUR_EP(addr), sizeof(SEp));
|
||||||
|
@ -1421,7 +1431,7 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) {
|
||||||
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t msgType = TDMT_VND_QUERY_HEARTBEAT_RSP;
|
int32_t msgType = TDMT_VND_QUERY_HEARTBEAT_RSP;
|
||||||
__async_send_cb_fn_t fp = NULL;
|
__async_send_cb_fn_t fp = NULL;
|
||||||
SCH_ERR_JRET(schGetCallbackFp(TDMT_VND_QUERY_HEARTBEAT, &fp));
|
SCH_ERR_JRET(schGetCallbackFp(TDMT_VND_QUERY_HEARTBEAT, &fp));
|
||||||
|
|
||||||
|
@ -1450,9 +1460,8 @@ _return:
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t schRegisterHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *epId, bool *exist) {
|
int32_t schRegisterHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *epId, bool *exist) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SSchHbTrans hb = {0};
|
SSchHbTrans hb = {0};
|
||||||
|
|
||||||
hb.trans.transInst = pJob->transport;
|
hb.trans.transInst = pJob->transport;
|
||||||
|
@ -1475,8 +1484,6 @@ int32_t schRegisterHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32_t schCloneCallbackParam(SSchCallbackParamHeader *pSrc, SSchCallbackParamHeader **pDst) {
|
int32_t schCloneCallbackParam(SSchCallbackParamHeader *pSrc, SSchCallbackParamHeader **pDst) {
|
||||||
if (pSrc->isHbParam) {
|
if (pSrc->isHbParam) {
|
||||||
SSchHbCallbackParam *dst = taosMemoryMalloc(sizeof(SSchHbCallbackParam));
|
SSchHbCallbackParam *dst = taosMemoryMalloc(sizeof(SSchHbCallbackParam));
|
||||||
|
@ -1505,7 +1512,7 @@ int32_t schCloneCallbackParam(SSchCallbackParamHeader *pSrc, SSchCallbackParamHe
|
||||||
|
|
||||||
int32_t schCloneSMsgSendInfo(void *src, void **dst) {
|
int32_t schCloneSMsgSendInfo(void *src, void **dst) {
|
||||||
SMsgSendInfo *pSrc = src;
|
SMsgSendInfo *pSrc = src;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SMsgSendInfo *pDst = taosMemoryMalloc(sizeof(*pSrc));
|
SMsgSendInfo *pDst = taosMemoryMalloc(sizeof(*pSrc));
|
||||||
if (NULL == pDst) {
|
if (NULL == pDst) {
|
||||||
qError("malloc SMsgSendInfo for rpcCtx failed, len:%d", (int32_t)sizeof(*pSrc));
|
qError("malloc SMsgSendInfo for rpcCtx failed, len:%d", (int32_t)sizeof(*pSrc));
|
||||||
|
@ -1541,10 +1548,10 @@ int32_t schCloneHbRpcCtx(SRpcCtx *pSrc, SRpcCtx *pDst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcCtxVal dst = {0};
|
SRpcCtxVal dst = {0};
|
||||||
void *pIter = taosHashIterate(pSrc->args, NULL);
|
void *pIter = taosHashIterate(pSrc->args, NULL);
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SRpcCtxVal *pVal = (SRpcCtxVal *)pIter;
|
SRpcCtxVal *pVal = (SRpcCtxVal *)pIter;
|
||||||
int32_t *msgType = taosHashGetKey(pIter, NULL);
|
int32_t *msgType = taosHashGetKey(pIter, NULL);
|
||||||
|
|
||||||
dst = *pVal;
|
dst = *pVal;
|
||||||
dst.val = NULL;
|
dst.val = NULL;
|
||||||
|
@ -1568,8 +1575,8 @@ _return:
|
||||||
SCH_RET(code);
|
SCH_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet *epSet, int32_t msgType, void *msg,
|
||||||
int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet* epSet, int32_t msgType, void *msg, uint32_t msgSize, bool persistHandle, SRpcCtx *ctx) {
|
uint32_t msgSize, bool persistHandle, SRpcCtx *ctx) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
SSchTrans *trans = (SSchTrans *)transport;
|
SSchTrans *trans = (SSchTrans *)transport;
|
||||||
|
@ -1601,11 +1608,11 @@ int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet*
|
||||||
pMsgSendInfo->msgType = msgType;
|
pMsgSendInfo->msgType = msgType;
|
||||||
pMsgSendInfo->fp = fp;
|
pMsgSendInfo->fp = fp;
|
||||||
|
|
||||||
qDebug("start to send %s msg to node[%d,%s,%d], refId:%" PRIx64 "instance:%p, handle:%p",
|
qDebug("start to send %s msg to node[%d,%s,%d], refId:%" PRIx64 "instance:%p, handle:%p", TMSG_INFO(msgType),
|
||||||
TMSG_INFO(msgType), ntohl(((SMsgHead *)msg)->vgId), epSet->eps[epSet->inUse].fqdn, epSet->eps[epSet->inUse].port,
|
ntohl(((SMsgHead *)msg)->vgId), epSet->eps[epSet->inUse].fqdn, epSet->eps[epSet->inUse].port, pJob->refId,
|
||||||
pJob->refId, trans->transInst, trans->transHandle);
|
trans->transInst, trans->transHandle);
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
int64_t transporterId = 0;
|
||||||
code = asyncSendMsgToServerExt(trans->transInst, epSet, &transporterId, pMsgSendInfo, persistHandle, ctx);
|
code = asyncSendMsgToServerExt(trans->transInst, epSet, &transporterId, pMsgSendInfo, persistHandle, ctx);
|
||||||
if (code) {
|
if (code) {
|
||||||
SCH_ERR_JRET(code);
|
SCH_ERR_JRET(code);
|
||||||
|
@ -1623,18 +1630,19 @@ _return:
|
||||||
|
|
||||||
int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) {
|
int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) {
|
||||||
SSchedulerHbReq req = {0};
|
SSchedulerHbReq req = {0};
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
SRpcCtx rpcCtx = {0};
|
SRpcCtx rpcCtx = {0};
|
||||||
SSchTrans trans = {0};
|
SSchTrans trans = {0};
|
||||||
int32_t msgType = TDMT_VND_QUERY_HEARTBEAT;
|
int32_t msgType = TDMT_VND_QUERY_HEARTBEAT;
|
||||||
|
|
||||||
req.header.vgId = htonl(nodeEpId->nodeId);
|
req.header.vgId = nodeEpId->nodeId;
|
||||||
req.sId = schMgmt.sId;
|
req.sId = schMgmt.sId;
|
||||||
memcpy(&req.epId, nodeEpId, sizeof(SQueryNodeEpId));
|
memcpy(&req.epId, nodeEpId, sizeof(SQueryNodeEpId));
|
||||||
|
|
||||||
SSchHbTrans *hb = taosHashGet(schMgmt.hbConnections, nodeEpId, sizeof(SQueryNodeEpId));
|
SSchHbTrans *hb = taosHashGet(schMgmt.hbConnections, nodeEpId, sizeof(SQueryNodeEpId));
|
||||||
if (NULL == hb) {
|
if (NULL == hb) {
|
||||||
qError("taosHashGet hb connection failed, nodeId:%d, fqdn:%s, port:%d", nodeEpId->nodeId, nodeEpId->ep.fqdn, nodeEpId->ep.port);
|
qError("taosHashGet hb connection failed, nodeId:%d, fqdn:%s, port:%d", nodeEpId->nodeId, nodeEpId->ep.fqdn,
|
||||||
|
nodeEpId->ep.port);
|
||||||
SCH_ERR_RET(code);
|
SCH_ERR_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1685,16 +1693,17 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) {
|
||||||
pMsgSendInfo->msgType = msgType;
|
pMsgSendInfo->msgType = msgType;
|
||||||
pMsgSendInfo->fp = fp;
|
pMsgSendInfo->fp = fp;
|
||||||
|
|
||||||
int64_t transporterId = 0;
|
int64_t transporterId = 0;
|
||||||
SEpSet epSet = {.inUse = 0, .numOfEps = 1};
|
SEpSet epSet = {.inUse = 0, .numOfEps = 1};
|
||||||
memcpy(&epSet.eps[0], &nodeEpId->ep, sizeof(nodeEpId->ep));
|
memcpy(&epSet.eps[0], &nodeEpId->ep, sizeof(nodeEpId->ep));
|
||||||
|
|
||||||
qDebug("start to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d", trans.transInst, trans.transHandle, nodeEpId->ep.fqdn, nodeEpId->ep.port);
|
qDebug("start to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d", trans.transInst, trans.transHandle,
|
||||||
|
nodeEpId->ep.fqdn, nodeEpId->ep.port);
|
||||||
|
|
||||||
code = asyncSendMsgToServerExt(trans.transInst, &epSet, &transporterId, pMsgSendInfo, true, &rpcCtx);
|
code = asyncSendMsgToServerExt(trans.transInst, &epSet, &transporterId, pMsgSendInfo, true, &rpcCtx);
|
||||||
if (code) {
|
if (code) {
|
||||||
qError("fail to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d, error:%x - %s",
|
qError("fail to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d, error:%x - %s", trans.transInst,
|
||||||
trans.transInst, trans.transHandle, nodeEpId->ep.fqdn, nodeEpId->ep.port, code, tstrerror(code));
|
trans.transHandle, nodeEpId->ep.fqdn, nodeEpId->ep.port, code, tstrerror(code));
|
||||||
SCH_ERR_JRET(code);
|
SCH_ERR_JRET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1712,11 +1721,11 @@ _return:
|
||||||
|
|
||||||
int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t msgType) {
|
int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t msgType) {
|
||||||
uint32_t msgSize = 0;
|
uint32_t msgSize = 0;
|
||||||
void *msg = NULL;
|
void *msg = NULL;
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
bool isCandidateAddr = false;
|
bool isCandidateAddr = false;
|
||||||
bool persistHandle = false;
|
bool persistHandle = false;
|
||||||
SRpcCtx rpcCtx = {0};
|
SRpcCtx rpcCtx = {0};
|
||||||
|
|
||||||
if (NULL == addr) {
|
if (NULL == addr) {
|
||||||
addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx);
|
addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx);
|
||||||
|
@ -1856,7 +1865,8 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
SCH_SET_TASK_LASTMSG_TYPE(pTask, msgType);
|
SCH_SET_TASK_LASTMSG_TYPE(pTask, msgType);
|
||||||
|
|
||||||
SSchTrans trans = {.transInst = pJob->transport, .transHandle = SCH_GET_TASK_HANDLE(pTask)};
|
SSchTrans trans = {.transInst = pJob->transport, .transHandle = SCH_GET_TASK_HANDLE(pTask)};
|
||||||
SCH_ERR_JRET(schAsyncSendMsg(pJob, pTask, &trans, &epSet, msgType, msg, msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL)));
|
SCH_ERR_JRET(schAsyncSendMsg(pJob, pTask, &trans, &epSet, msgType, msg, msgSize, persistHandle,
|
||||||
|
(rpcCtx.args ? &rpcCtx : NULL)));
|
||||||
|
|
||||||
if (msgType == TDMT_VND_QUERY) {
|
if (msgType == TDMT_VND_QUERY) {
|
||||||
SCH_ERR_RET(schRecordTaskExecNode(pJob, pTask, addr, trans.transHandle));
|
SCH_ERR_RET(schRecordTaskExecNode(pJob, pTask, addr, trans.transHandle));
|
||||||
|
|
Loading…
Reference in New Issue