Merge pull request #18535 from taosdata/enh/addTraceInfo
enh: add trace info
This commit is contained in:
commit
fd31980b91
|
@ -169,6 +169,9 @@ void taosSetMaskSIGPIPE();
|
||||||
uint32_t taosInetAddr(const char *ipAddr);
|
uint32_t taosInetAddr(const char *ipAddr);
|
||||||
const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len);
|
const char *taosInetNtoa(struct in_addr ipInt, char *dstStr, int32_t len);
|
||||||
|
|
||||||
|
uint64_t taosHton64(uint64_t val);
|
||||||
|
uint64_t taosNtoh64(uint64_t val);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -169,6 +169,7 @@ typedef struct {
|
||||||
char spi : 2;
|
char spi : 2;
|
||||||
char hasEpSet : 2; // contain epset or not, 0(default): no epset, 1: contain epset
|
char hasEpSet : 2; // contain epset or not, 0(default): no epset, 1: contain epset
|
||||||
|
|
||||||
|
uint64_t timestamp;
|
||||||
char user[TSDB_UNI_LEN];
|
char user[TSDB_UNI_LEN];
|
||||||
uint32_t magicNum;
|
uint32_t magicNum;
|
||||||
STraceId traceId;
|
STraceId traceId;
|
||||||
|
|
|
@ -758,6 +758,14 @@ static void cliSendCb(uv_write_t* req, int status) {
|
||||||
SCliConn* pConn = transReqQueueRemove(req);
|
SCliConn* pConn = transReqQueueRemove(req);
|
||||||
if (pConn == NULL) return;
|
if (pConn == NULL) return;
|
||||||
|
|
||||||
|
SCliMsg* pMsg = !transQueueEmpty(&pConn->cliMsgs) ? transQueueGet(&pConn->cliMsgs, 0) : NULL;
|
||||||
|
if (pMsg != NULL) {
|
||||||
|
int64_t cost = taosGetTimestampUs() - pMsg->st;
|
||||||
|
if (cost > 1000) {
|
||||||
|
tWarn("%s conn %p send cost:%dus, send exception", CONN_GET_INST_LABEL(pConn), pConn, (int)cost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
tTrace("%s conn %p data already was written out", CONN_GET_INST_LABEL(pConn), pConn);
|
tTrace("%s conn %p data already was written out", CONN_GET_INST_LABEL(pConn), pConn);
|
||||||
} else {
|
} else {
|
||||||
|
@ -806,6 +814,7 @@ void cliSend(SCliConn* pConn) {
|
||||||
pHead->traceId = pMsg->info.traceId;
|
pHead->traceId = pMsg->info.traceId;
|
||||||
pHead->magicNum = htonl(TRANS_MAGIC_NUM);
|
pHead->magicNum = htonl(TRANS_MAGIC_NUM);
|
||||||
}
|
}
|
||||||
|
pHead->timestamp = taosHton64(taosGetTimestampUs());
|
||||||
|
|
||||||
if (pHead->persist == 1) {
|
if (pHead->persist == 1) {
|
||||||
CONN_SET_PERSIST_BY_APP(pConn);
|
CONN_SET_PERSIST_BY_APP(pConn);
|
||||||
|
@ -1662,6 +1671,7 @@ int transReleaseCliHandle(void* handle) {
|
||||||
|
|
||||||
SCliMsg* cmsg = taosMemoryCalloc(1, sizeof(SCliMsg));
|
SCliMsg* cmsg = taosMemoryCalloc(1, sizeof(SCliMsg));
|
||||||
cmsg->msg = tmsg;
|
cmsg->msg = tmsg;
|
||||||
|
cmsg->st = taosGetTimestampUs();
|
||||||
cmsg->type = Release;
|
cmsg->type = Release;
|
||||||
cmsg->ctx = pCtx;
|
cmsg->ctx = pCtx;
|
||||||
|
|
||||||
|
|
|
@ -231,14 +231,29 @@ static bool uvHandleReq(SSvrConn* pConn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
STraceId* trace = &pHead->traceId;
|
STraceId* trace = &pHead->traceId;
|
||||||
|
|
||||||
|
int64_t cost = taosGetTimestampUs() - taosNtoh64(pHead->timestamp);
|
||||||
|
static int64_t EXCEPTION_LIMIT_US = 100 * 1000;
|
||||||
|
|
||||||
if (pConn->status == ConnNormal && pHead->noResp == 0) {
|
if (pConn->status == ConnNormal && pHead->noResp == 0) {
|
||||||
transRefSrvHandle(pConn);
|
transRefSrvHandle(pConn);
|
||||||
|
if (cost >= EXCEPTION_LIMIT_US) {
|
||||||
tGDebug("%s conn %p %s received from %s, local info:%s, len:%d", transLabel(pTransInst), pConn,
|
tGWarn("%s conn %p %s received from %s, local info:%s, len:%d, cost:%dus, recv exception", transLabel(pTransInst),
|
||||||
TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, msgLen);
|
pConn, TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, msgLen, (int)cost);
|
||||||
} else {
|
} else {
|
||||||
tGDebug("%s conn %p %s received from %s, local info:%s, len:%d, resp:%d, code:%d", transLabel(pTransInst), pConn,
|
tGDebug("%s conn %p %s received from %s, local info:%s, len:%d, cost:%dus", transLabel(pTransInst), pConn,
|
||||||
TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, msgLen, pHead->noResp, transMsg.code);
|
TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, msgLen, (int)cost);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (cost >= EXCEPTION_LIMIT_US) {
|
||||||
|
tGWarn("%s conn %p %s received from %s, local info:%s, len:%d, resp:%d, code:%d, cost:%dus, recv exception",
|
||||||
|
transLabel(pTransInst), pConn, TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, msgLen, pHead->noResp,
|
||||||
|
transMsg.code, (int)(cost));
|
||||||
|
} else {
|
||||||
|
tGWarn("%s conn %p %s received from %s, local info:%s, len:%d, resp:%d, code:%d, cost:%dus",
|
||||||
|
transLabel(pTransInst), pConn, TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, msgLen, pHead->noResp,
|
||||||
|
transMsg.code, (int)(cost));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pHead->noResp = 1,
|
// pHead->noResp = 1,
|
||||||
|
|
|
@ -1103,3 +1103,30 @@ void taosWinSocketInit() {
|
||||||
#else
|
#else
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t taosHton64(uint64_t val) {
|
||||||
|
#if defined(WINDOWS) || defined(DARWIN)
|
||||||
|
return ((val & 0x00000000000000ff) << 7 * 8) | ((val & 0x000000000000ff00) << 5 * 8) |
|
||||||
|
((val & 0x0000000000ff0000) << 3 * 8) | ((val & 0x00000000ff000000) << 1 * 8) |
|
||||||
|
((val & 0x000000ff00000000) >> 1 * 8) | ((val & 0x0000ff0000000000) >> 3 * 8) |
|
||||||
|
((val & 0x00ff000000000000) >> 5 * 8) | ((val & 0xff00000000000000) >> 7 * 8);
|
||||||
|
#else
|
||||||
|
if (__BYTE_ORDER == __LITTLE_ENDIAN) {
|
||||||
|
return (((uint64_t)htonl((int)((val << 32) >> 32))) << 32) | (unsigned int)htonl((int)(val >> 32));
|
||||||
|
} else if (__BYTE_ORDER == __BIG_ENDIAN) {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t taosNtoh64(uint64_t val) {
|
||||||
|
#if defined(WINDOWS) || defined(DARWIN)
|
||||||
|
return taosHton64(val);
|
||||||
|
#else
|
||||||
|
if (__BYTE_ORDER == __LITTLE_ENDIAN) {
|
||||||
|
return (((uint64_t)htonl((int)((val << 32) >> 32))) << 32) | (unsigned int)htonl((int)(val >> 32));
|
||||||
|
} else if (__BYTE_ORDER == __BIG_ENDIAN) {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ class TDTestCase:
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
print(f"start taosd run")
|
||||||
bPath=self.getBuildPath()
|
bPath=self.getBuildPath()
|
||||||
cPath=self.getCfgPath()
|
cPath=self.getCfgPath()
|
||||||
dbname = "test"
|
dbname = "test"
|
||||||
|
@ -86,17 +87,20 @@ class TDTestCase:
|
||||||
tableNumbers=100
|
tableNumbers=100
|
||||||
recordNumbers1=100
|
recordNumbers1=100
|
||||||
recordNumbers2=1000
|
recordNumbers2=1000
|
||||||
tdsqlF=tdCom.newTdSql()
|
#tdsqlF=tdCom.newTdSql()
|
||||||
print(tdsqlF)
|
#print(tdsqlF)
|
||||||
tdsqlF.query(f"SELECT SERVER_VERSION();")
|
|
||||||
print(tdsqlF.query(f"SELECT SERVER_VERSION();"))
|
|
||||||
oldServerVersion=tdsqlF.queryResult[0][0]
|
|
||||||
tdLog.info(f"Base server version is {oldServerVersion}")
|
|
||||||
tdsqlF.query(f"SELECT CLIENT_VERSION();")
|
|
||||||
|
|
||||||
# the oldClientVersion can't be updated in the same python process,so the version is new compiled verison
|
oldServerVersion = '3.0.1.0'
|
||||||
oldClientVersion=tdsqlF.queryResult[0][0]
|
#tdsqlF.query(f"SELECT SERVER_VERSION();")
|
||||||
tdLog.info(f"Base client version is {oldClientVersion}")
|
#print(tdsqlF.query(f"SELECT SERVER_VERSION();"))
|
||||||
|
#oldServerVersion=tdsqlF.queryResult[0][0]
|
||||||
|
#tdLog.info(f"Base server version is {oldServerVersion}")
|
||||||
|
#tdsqlF.query(f"SELECT CLIENT_VERSION();")
|
||||||
|
#
|
||||||
|
## the oldClientVersion can't be updated in the same python process,so the version is new compiled verison
|
||||||
|
#oldClientVersion=tdsqlF.queryResult[0][0]
|
||||||
|
|
||||||
|
#tdLog.info(f"Base client version is {oldClientVersion}")
|
||||||
|
|
||||||
tdLog.printNoPrefix(f"==========step1:prepare and check data in old version-{oldServerVersion}")
|
tdLog.printNoPrefix(f"==========step1:prepare and check data in old version-{oldServerVersion}")
|
||||||
tdLog.info(f" LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ")
|
tdLog.info(f" LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ")
|
||||||
|
|
Loading…
Reference in New Issue