refactor tq backend

This commit is contained in:
Yihao Deng 2024-07-23 11:49:31 +00:00
parent 7880800bee
commit 0b4031ed6a
1 changed files with 16 additions and 2 deletions

View File

@ -1601,7 +1601,9 @@ FORCE_INLINE int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* pResp) {
memset(pResp, 0, sizeof(STransMsg)); memset(pResp, 0, sizeof(STransMsg));
if (pResp->code == 0) {
pResp->code = TSDB_CODE_RPC_BROKEN_LINK; pResp->code = TSDB_CODE_RPC_BROKEN_LINK;
}
pResp->msgType = pMsg->msg.msgType + 1; pResp->msgType = pMsg->msg.msgType + 1;
pResp->info.ahandle = pMsg->ctx ? pMsg->ctx->ahandle : NULL; pResp->info.ahandle = pMsg->ctx ? pMsg->ctx->ahandle : NULL;
pResp->info.traceId = pMsg->msg.info.traceId; pResp->info.traceId = pMsg->msg.info.traceId;
@ -1697,7 +1699,7 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
SCliConn* conn = cliGetConn(&pMsg, pThrd, &ignore, addr); SCliConn* conn = cliGetConn(&pMsg, pThrd, &ignore, addr);
if (ignore == true) { if (ignore == true) {
// persist conn already release by server // persist conn already release by server
STransMsg resp; STransMsg resp = {0};
cliBuildExceptResp(pMsg, &resp); cliBuildExceptResp(pMsg, &resp);
// refactorr later // refactorr later
resp.info.cliVer = pTransInst->compatibilityVer; resp.info.cliVer = pTransInst->compatibilityVer;
@ -1719,6 +1721,18 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
cliSend(conn); cliSend(conn);
} else { } else {
code = cliCreateConn(pThrd, &conn); code = cliCreateConn(pThrd, &conn);
if (code != 0) {
tError("%s failed to create conn, reason:%s", pTransInst->label, tstrerror(code));
STransMsg resp = {.code = code};
cliBuildExceptResp(pMsg, &resp);
resp.info.cliVer = pTransInst->compatibilityVer;
if (pMsg->type != Release) {
pTransInst->cfp(pTransInst->parent, &resp, NULL);
}
destroyCmsg(pMsg);
return;
}
int64_t refId = (int64_t)pMsg->msg.info.handle; int64_t refId = (int64_t)pMsg->msg.info.handle;
if (refId != 0) specifyConnRef(conn, true, refId); if (refId != 0) specifyConnRef(conn, true, refId);