add user req

This commit is contained in:
yihaoDeng 2024-09-29 14:16:00 +08:00
parent 10884dd534
commit 545a9d74e9
2 changed files with 20 additions and 7 deletions

View File

@ -2481,7 +2481,9 @@ FORCE_INLINE bool cliTryUpdateEpset(SCliReq* pReq, STransMsg* pResp) {
pResp->info.hasEpSet = 1; pResp->info.hasEpSet = 1;
transCreateReqEpsetFromUserEpset(&epset, &ctx->epSet); if (transCreateReqEpsetFromUserEpset(&epset, &ctx->epSet) != 0) {
return false;
}
return true; return true;
} }
@ -2510,7 +2512,9 @@ bool cliResetEpset(SReqCtx* pCtx, STransMsg* pResp, bool hasEpSet) {
transPrintEpSet((SEpSet*)pCtx->epSet); transPrintEpSet((SEpSet*)pCtx->epSet);
transPrintEpSet(&epSet); transPrintEpSet(&epSet);
transCreateReqEpsetFromUserEpset(&epSet, &pCtx->epSet); if (transCreateReqEpsetFromUserEpset(&epSet, &pCtx->epSet) != 0) {
tDebug("failed to create req epset from user epset");
}
noDelay = false; noDelay = false;
} else { } else {
if (pCtx->epsetRetryCnt >= pCtx->epSet->numOfEps) { if (pCtx->epsetRetryCnt >= pCtx->epSet->numOfEps) {
@ -2537,7 +2541,9 @@ bool cliResetEpset(SReqCtx* pCtx, STransMsg* pResp, bool hasEpSet) {
tDebug("epset not equal, retry new epset2"); tDebug("epset not equal, retry new epset2");
transPrintEpSet((SEpSet*)pCtx->epSet); transPrintEpSet((SEpSet*)pCtx->epSet);
transPrintEpSet(&epSet); transPrintEpSet(&epSet);
transCreateReqEpsetFromUserEpset(&epSet, &pCtx->epSet); if (transCreateReqEpsetFromUserEpset(&epSet, &pCtx->epSet) != 0) {
tError("failed to create req epset from user epset");
}
noDelay = false; noDelay = false;
} else { } else {
if (pCtx->epsetRetryCnt >= pCtx->epSet->numOfEps) { if (pCtx->epsetRetryCnt >= pCtx->epSet->numOfEps) {
@ -2721,7 +2727,9 @@ int32_t cliNotifyImplCb(SCliConn* pConn, SCliReq* pReq, STransMsg* pResp) {
pSyncMsg->hasEpSet = 1; pSyncMsg->hasEpSet = 1;
SEpSet epset = {0}; SEpSet epset = {0};
transCreateUserEpsetFromReqEpset(pCtx->epSet, &epset); if (transCreateUserEpsetFromReqEpset(pCtx->epSet, &epset) != 0) {
tError("failed to create user epset from req epset");
}
epsetAssign(&pSyncMsg->epSet, &epset); epsetAssign(&pSyncMsg->epSet, &epset);
} }
TAOS_UNUSED(tsem2_post(pSyncMsg->pSem)); TAOS_UNUSED(tsem2_post(pSyncMsg->pSem));
@ -2734,14 +2742,18 @@ int32_t cliNotifyImplCb(SCliConn* pConn, SCliReq* pReq, STransMsg* pResp) {
tGTrace("%s conn %p handle resp", CONN_GET_INST_LABEL(pConn), pConn); tGTrace("%s conn %p handle resp", CONN_GET_INST_LABEL(pConn), pConn);
if (pResp->info.hasEpSet == 1) { if (pResp->info.hasEpSet == 1) {
SEpSet epset = {0}; SEpSet epset = {0};
transCreateUserEpsetFromReqEpset(pCtx->epSet, &epset); if (transCreateUserEpsetFromReqEpset(pCtx->epSet, &epset) != 0) {
tError("failed to create user epset from req epset");
}
pInst->cfp(pInst->parent, pResp, &epset); pInst->cfp(pInst->parent, pResp, &epset);
} else { } else {
if (!cliIsEpsetUpdated(pResp->code, pCtx)) { if (!cliIsEpsetUpdated(pResp->code, pCtx)) {
pInst->cfp(pInst->parent, pResp, NULL); pInst->cfp(pInst->parent, pResp, NULL);
} else { } else {
SEpSet epset = {0}; SEpSet epset = {0};
transCreateUserEpsetFromReqEpset(pCtx->epSet, &epset); if (transCreateUserEpsetFromReqEpset(pCtx->epSet, &epset) != 0) {
tError("failed to create user epset from req epset");
}
pInst->cfp(pInst->parent, pResp, &epset); pInst->cfp(pInst->parent, pResp, &epset);
} }
} }

View File

@ -944,7 +944,6 @@ int32_t transCreateReqEpsetFromUserEpset(const SEpSet* pEpset, SReqEpSet** pReqE
if (pReqEpSet == NULL) { if (pReqEpSet == NULL) {
return TSDB_CODE_INVALID_PARA; return TSDB_CODE_INVALID_PARA;
} }
taosMemoryFree(*pReqEpSet);
int32_t size = sizeof(SReqEpSet) + sizeof(SEp) * pEpset->numOfEps; int32_t size = sizeof(SReqEpSet) + sizeof(SEp) * pEpset->numOfEps;
SReqEpSet* pReq = (SReqEpSet*)taosMemoryCalloc(1, size); SReqEpSet* pReq = (SReqEpSet*)taosMemoryCalloc(1, size);
@ -952,6 +951,8 @@ int32_t transCreateReqEpsetFromUserEpset(const SEpSet* pEpset, SReqEpSet** pReqE
return TSDB_CODE_OUT_OF_MEMORY; return TSDB_CODE_OUT_OF_MEMORY;
} }
memcpy((char*)pReq, (char*)pEpset, size); memcpy((char*)pReq, (char*)pEpset, size);
taosMemoryFree(*pReqEpSet);
*pReqEpSet = pReq; *pReqEpSet = pReq;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }