Merge pull request #20142 from taosdata/enh/optTrans
fix: opt trans debug info
This commit is contained in:
commit
a7ad2990cb
|
@ -22,6 +22,7 @@ extern "C" {
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "theap.h"
|
#include "theap.h"
|
||||||
|
#include "tmisce.h"
|
||||||
#include "transLog.h"
|
#include "transLog.h"
|
||||||
#include "transportInt.h"
|
#include "transportInt.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "transComm.h"
|
#include "transComm.h"
|
||||||
|
|
||||||
typedef struct SConnList {
|
typedef struct SConnList {
|
||||||
|
@ -224,9 +223,13 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
// snprintf may cause performance problem
|
// snprintf may cause performance problem
|
||||||
#define CONN_CONSTRUCT_HASH_KEY(key, ip, port) \
|
#define CONN_CONSTRUCT_HASH_KEY(key, ip, port) \
|
||||||
do { \
|
do { \
|
||||||
snprintf(key, sizeof(key), "%s:%d", ip, (int)port); \
|
char* p = key; \
|
||||||
|
int32_t len = strlen(ip); \
|
||||||
|
if (p != NULL) memcpy(p, ip, len); \
|
||||||
|
p[len] = ':'; \
|
||||||
|
titoa(port, 10, &p[len + 1]); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define CONN_PERSIST_TIME(para) ((para) <= 90000 ? 90000 : (para))
|
#define CONN_PERSIST_TIME(para) ((para) <= 90000 ? 90000 : (para))
|
||||||
|
@ -664,7 +667,7 @@ static int32_t specifyConnRef(SCliConn* conn, bool update, int64_t handle) {
|
||||||
static void cliAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
|
static void cliAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
|
||||||
SCliConn* conn = handle->data;
|
SCliConn* conn = handle->data;
|
||||||
SConnBuffer* pBuf = &conn->readBuf;
|
SConnBuffer* pBuf = &conn->readBuf;
|
||||||
tDebug("%s conn %p alloc read buf", CONN_GET_INST_LABEL(conn), conn);
|
tTrace("%s conn %p alloc read buf", CONN_GET_INST_LABEL(conn), conn);
|
||||||
transAllocBuffer(pBuf, buf);
|
transAllocBuffer(pBuf, buf);
|
||||||
}
|
}
|
||||||
static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
|
static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
|
||||||
|
@ -677,7 +680,7 @@ static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
|
||||||
if (nread > 0) {
|
if (nread > 0) {
|
||||||
pBuf->len += nread;
|
pBuf->len += nread;
|
||||||
while (transReadComplete(pBuf)) {
|
while (transReadComplete(pBuf)) {
|
||||||
tDebug("%s conn %p read complete", CONN_GET_INST_LABEL(conn), conn);
|
tTrace("%s conn %p read complete", CONN_GET_INST_LABEL(conn), conn);
|
||||||
if (pBuf->invalid) {
|
if (pBuf->invalid) {
|
||||||
cliHandleExcept(conn);
|
cliHandleExcept(conn);
|
||||||
break;
|
break;
|
||||||
|
@ -1949,11 +1952,13 @@ static void cliSchedMsgToNextNode(SCliMsg* pMsg, SCliThrd* pThrd) {
|
||||||
STrans* pTransInst = pThrd->pTransInst;
|
STrans* pTransInst = pThrd->pTransInst;
|
||||||
STransConnCtx* pCtx = pMsg->ctx;
|
STransConnCtx* pCtx = pMsg->ctx;
|
||||||
|
|
||||||
STraceId* trace = &pMsg->msg.info.traceId;
|
if (rpcDebugFlag & DEBUG_DEBUG) {
|
||||||
char tbuf[256] = {0};
|
STraceId* trace = &pMsg->msg.info.traceId;
|
||||||
EPSET_DEBUG_STR(&pCtx->epSet, tbuf);
|
char tbuf[256] = {0};
|
||||||
tGDebug("%s retry on next node,use:%s, step: %d,timeout:%" PRId64 "", transLabel(pThrd->pTransInst), tbuf,
|
EPSET_DEBUG_STR(&pCtx->epSet, tbuf);
|
||||||
pCtx->retryStep, pCtx->retryNextInterval);
|
tGDebug("%s retry on next node,use:%s, step: %d,timeout:%" PRId64 "", transLabel(pThrd->pTransInst), tbuf,
|
||||||
|
pCtx->retryStep, pCtx->retryNextInterval);
|
||||||
|
}
|
||||||
|
|
||||||
STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg));
|
STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg));
|
||||||
arg->param1 = pMsg;
|
arg->param1 = pMsg;
|
||||||
|
@ -1990,7 +1995,7 @@ FORCE_INLINE bool cliTryExtractEpSet(STransMsg* pResp, SEpSet* dst) {
|
||||||
pResp->pCont = buf;
|
pResp->pCont = buf;
|
||||||
pResp->contLen = len;
|
pResp->contLen = len;
|
||||||
|
|
||||||
*dst = epset;
|
epsetAssign(dst, &epset);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool cliResetEpset(STransConnCtx* pCtx, STransMsg* pResp, bool hasEpSet) {
|
bool cliResetEpset(STransConnCtx* pCtx, STransMsg* pResp, bool hasEpSet) {
|
||||||
|
@ -2015,7 +2020,7 @@ bool cliResetEpset(STransConnCtx* pCtx, STransMsg* pResp, bool hasEpSet) {
|
||||||
} else {
|
} else {
|
||||||
if (!transEpSetIsEqual(&pCtx->epSet, &epSet)) {
|
if (!transEpSetIsEqual(&pCtx->epSet, &epSet)) {
|
||||||
tDebug("epset not equal, retry new epset");
|
tDebug("epset not equal, retry new epset");
|
||||||
pCtx->epSet = epSet;
|
epsetAssign(&pCtx->epSet, &epSet);
|
||||||
noDelay = false;
|
noDelay = false;
|
||||||
} else {
|
} else {
|
||||||
if (pCtx->epsetRetryCnt >= pCtx->epSet.numOfEps) {
|
if (pCtx->epsetRetryCnt >= pCtx->epSet.numOfEps) {
|
||||||
|
@ -2040,7 +2045,7 @@ bool cliResetEpset(STransConnCtx* pCtx, STransMsg* pResp, bool hasEpSet) {
|
||||||
} else {
|
} else {
|
||||||
if (!transEpSetIsEqual(&pCtx->epSet, &epSet)) {
|
if (!transEpSetIsEqual(&pCtx->epSet, &epSet)) {
|
||||||
tDebug("epset not equal, retry new epset");
|
tDebug("epset not equal, retry new epset");
|
||||||
pCtx->epSet = epSet;
|
epsetAssign(&pCtx->epSet, &epSet);
|
||||||
noDelay = false;
|
noDelay = false;
|
||||||
} else {
|
} else {
|
||||||
if (pCtx->epsetRetryCnt >= pCtx->epSet.numOfEps) {
|
if (pCtx->epsetRetryCnt >= pCtx->epSet.numOfEps) {
|
||||||
|
@ -2130,10 +2135,6 @@ bool cliGenRetryRule(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
||||||
if (pCtx->retryNextInterval >= pCtx->retryMaxInterval) {
|
if (pCtx->retryNextInterval >= pCtx->retryMaxInterval) {
|
||||||
pCtx->retryNextInterval = pCtx->retryMaxInterval;
|
pCtx->retryNextInterval = pCtx->retryMaxInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (-1 != pCtx->retryMaxTimeout && taosGetTimestampMs() - pCtx->retryInitTimestamp >= pCtx->retryMaxTimeout) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
pCtx->retryNextInterval = 0;
|
pCtx->retryNextInterval = 0;
|
||||||
pCtx->epsetRetryCnt++;
|
pCtx->epsetRetryCnt++;
|
||||||
|
@ -2181,9 +2182,11 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
|
||||||
STraceId* trace = &pResp->info.traceId;
|
STraceId* trace = &pResp->info.traceId;
|
||||||
bool hasEpSet = cliTryExtractEpSet(pResp, &pCtx->epSet);
|
bool hasEpSet = cliTryExtractEpSet(pResp, &pCtx->epSet);
|
||||||
if (hasEpSet) {
|
if (hasEpSet) {
|
||||||
char tbuf[256] = {0};
|
if (rpcDebugFlag & DEBUG_TRACE) {
|
||||||
EPSET_DEBUG_STR(&pCtx->epSet, tbuf);
|
char tbuf[256] = {0};
|
||||||
tGTrace("%s conn %p extract epset from msg", CONN_GET_INST_LABEL(pConn), pConn);
|
EPSET_DEBUG_STR(&pCtx->epSet, tbuf);
|
||||||
|
tGTrace("%s conn %p extract epset from msg", CONN_GET_INST_LABEL(pConn), pConn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCtx->pSem != NULL) {
|
if (pCtx->pSem != NULL) {
|
||||||
|
@ -2310,8 +2313,9 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran
|
||||||
|
|
||||||
TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64());
|
TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64());
|
||||||
STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
|
STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
|
||||||
pCtx->epSet = *pEpSet;
|
epsetAssign(&pCtx->epSet, pEpSet);
|
||||||
pCtx->origEpSet = *pEpSet;
|
epsetAssign(&pCtx->origEpSet, pEpSet);
|
||||||
|
|
||||||
pCtx->ahandle = pReq->info.ahandle;
|
pCtx->ahandle = pReq->info.ahandle;
|
||||||
pCtx->msgType = pReq->msgType;
|
pCtx->msgType = pReq->msgType;
|
||||||
|
|
||||||
|
@ -2356,8 +2360,8 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs
|
||||||
TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64());
|
TRACE_SET_MSGID(&pReq->info.traceId, tGenIdPI64());
|
||||||
|
|
||||||
STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
|
STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
|
||||||
pCtx->epSet = *pEpSet;
|
epsetAssign(&pCtx->epSet, pEpSet);
|
||||||
pCtx->origEpSet = *pEpSet;
|
epsetAssign(&pCtx->origEpSet, pEpSet);
|
||||||
pCtx->ahandle = pReq->info.ahandle;
|
pCtx->ahandle = pReq->info.ahandle;
|
||||||
pCtx->msgType = pReq->msgType;
|
pCtx->msgType = pReq->msgType;
|
||||||
pCtx->pSem = sem;
|
pCtx->pSem = sem;
|
||||||
|
|
Loading…
Reference in New Issue