From 84706fe58680045ff4bb24ca1fa407831865dd2c Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Fri, 24 Feb 2023 21:20:15 +0800 Subject: [PATCH] fix: limit session num --- include/common/tglobal.h | 1 + include/libs/transport/trpc.h | 2 +- source/client/src/clientEnv.c | 1 + source/client/src/clientImpl.c | 1 + source/common/src/tglobal.c | 4 ++-- source/dnode/mgmt/node_mgmt/src/dmTransport.c | 1 + source/libs/transport/inc/transportInt.h | 10 +++++----- source/libs/transport/src/trans.c | 2 +- source/libs/transport/src/transCli.c | 2 +- tools/shell/src/shellNettest.c | 3 ++- 10 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index e92afc2222..26bd6fa163 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -50,6 +50,7 @@ extern int32_t tsTagFilterResCacheSize; // queue & threads extern int32_t tsNumOfRpcThreads; extern int32_t tsNumOfRpcSessions; +extern int32_t tsTimeToGetAvailableConn; extern int32_t tsNumOfCommitThreads; extern int32_t tsNumOfTaskQueueThreads; extern int32_t tsNumOfMnodeQueryThreads; diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index 0cc0ab64ef..c73e5c127a 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -114,7 +114,7 @@ typedef struct SRpcInit { int32_t connLimitNum; int32_t connLimitLock; - + int32_t timeToGetConn; int8_t supportBatch; // 0: no batch, 1. batch int32_t batchSize; void *parent; diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 6122a1d465..53fe2c7ff3 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -159,6 +159,7 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) { connLimitNum = TMAX(connLimitNum, 10); connLimitNum = TMIN(connLimitNum, 500); rpcInit.connLimitNum = connLimitNum; + rpcInit.timeToGetConn = tsTimeToGetAvailableConn; void *pDnodeConn = rpcOpen(&rpcInit); if (pDnodeConn == NULL) { diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index c85e761c0b..e8751e5b1d 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -2012,6 +2012,7 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de connLimitNum = TMAX(connLimitNum, 10); connLimitNum = TMIN(connLimitNum, 500); rpcInit.connLimitNum = connLimitNum; + rpcInit.timeToGetConn = tsTimeToGetAvailableConn; clientRpc = rpcOpen(&rpcInit); if (clientRpc == NULL) { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 727663ba65..adf2c246c4 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -41,8 +41,8 @@ bool tsPrintAuth = false; // queue & threads int32_t tsNumOfRpcThreads = 1; -int32_t tsNumOfRpcSessions = 2000; -int32_t tsTimeToGetAvailableConn = 1000; +int32_t tsNumOfRpcSessions = 10000; +int32_t tsTimeToGetAvailableConn = 10000; int32_t tsNumOfCommitThreads = 2; int32_t tsNumOfTaskQueueThreads = 4; int32_t tsNumOfMnodeQueryThreads = 4; diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index 3a1ca161a9..0245847b20 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -292,6 +292,7 @@ int32_t dmInitClient(SDnode *pDnode) { rpcInit.connLimitLock = 1; rpcInit.supportBatch = 1; rpcInit.batchSize = 8 * 1024; + rpcInit.timeToGetConn = tsTimeToGetAvailableConn; pTrans->clientRpc = rpcOpen(&rpcInit); if (pTrans->clientRpc == NULL) { diff --git a/source/libs/transport/inc/transportInt.h b/source/libs/transport/inc/transportInt.h index 1f3c98ad72..8ea0064d44 100644 --- a/source/libs/transport/inc/transportInt.h +++ b/source/libs/transport/inc/transportInt.h @@ -64,11 +64,11 @@ typedef struct { void (*destroyFp)(void* ahandle); bool (*failFastFp)(tmsg_t msgType); - int32_t connLimitNum; - int8_t connLimitLock; // 0: no lock. 1. lock - int8_t supportBatch; // 0: no batch, 1: support batch - int32_t batchSize; - + int32_t connLimitNum; + int8_t connLimitLock; // 0: no lock. 1. lock + int8_t supportBatch; // 0: no batch, 1: support batch + int32_t batchSize; + int32_t timeToGetConn; int index; void* parent; void* tcphandle; // returned handle from TCP initialization diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index f5f3b52f50..35b48fea6b 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -90,7 +90,7 @@ void* rpcOpen(const SRpcInit* pInit) { if (pInit->user) { tstrncpy(pRpc->user, pInit->user, sizeof(pRpc->user)); } - + pRpc->timeToGetConn = pInit->timeToGetConn; pRpc->tcphandle = (*taosInitHandle[pRpc->connType])(ip, pInit->localPort, pRpc->label, pRpc->numOfThreads, NULL, pRpc); diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 128d9b8162..d002366a12 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -1422,7 +1422,7 @@ static int32_t cliPreCheckSessionLimitForMsg(SCliThrd* pThrd, char* addr, SCliMs arg->param1 = pMsg; arg->param2 = pThrd; - pMsg->ctx->task = transDQSched(pThrd->waitConnQueue, doFreeTimeoutMsg, arg, 200); + pMsg->ctx->task = transDQSched(pThrd->waitConnQueue, doFreeTimeoutMsg, arg, pTransInst->timeToGetConn); tGTrace("%s msg %s delay to send, wait for avaiable connect", pTransInst->label, TMSG_INFO(pMsg->msg.msgType)); QUEUE_PUSH(&(*list)->msgQ, &pMsg->q); return -1; diff --git a/tools/shell/src/shellNettest.c b/tools/shell/src/shellNettest.c index 52ce37b22c..1a6ac3489d 100644 --- a/tools/shell/src/shellNettest.c +++ b/tools/shell/src/shellNettest.c @@ -21,7 +21,7 @@ static void shellWorkAsClient() { SRpcInit rpcInit = {0}; SEpSet epSet = {.inUse = 0, .numOfEps = 1}; SRpcMsg rpcRsp = {0}; - void * clientRpc = NULL; + void *clientRpc = NULL; char pass[TSDB_PASSWORD_LEN + 1] = {0}; taosEncryptPass_c((uint8_t *)("_pwd"), strlen("_pwd"), pass); @@ -31,6 +31,7 @@ static void shellWorkAsClient() { rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.idleTime = tsShellActivityTimer * 1000; rpcInit.user = "_dnd"; + rpcInit.timeToGetConn = tsTimeToGetAvailableConn; clientRpc = rpcOpen(&rpcInit); if (clientRpc == NULL) { -- GitLab