From b74525bc5e2472ae8ba8c44d10c66a474629e360 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Thu, 16 Sep 2021 16:14:54 +0800 Subject: [PATCH] [TD-6663] support rpcForceTcp --- src/common/inc/tglobal.h | 1 + src/common/src/tglobal.c | 11 +++++++++++ src/rpc/src/rpcMain.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 07d614d5ef..131c412575 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -45,6 +45,7 @@ extern int32_t tsDnodeId; // common extern int tsRpcTimer; extern int tsRpcMaxTime; +extern int tsRpcForceTcp; // all commands go to tcp protocol if this is enabled extern int32_t tsMaxConnections; extern int32_t tsMaxShellConns; extern int32_t tsShellActivityTimer; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 198d57b6b9..c93824ff35 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -54,6 +54,7 @@ int32_t tsRpcTimer = 300; int32_t tsRpcMaxTime = 600; // seconds; int32_t tsMaxShellConns = 50000; int32_t tsMaxConnections = 5000; +int32_t tsRpcForceTcp = 0; //disable this, means query, show command use udp protocol as default int32_t tsShellActivityTimer = 3; // second float tsNumOfThreadsPerCore = 1.0f; int32_t tsNumOfCommitThreads = 4; @@ -639,6 +640,16 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_SECOND; taosInitConfigOption(cfg); + cfg.option = "rpcForceTcp"; + cfg.ptr = &tsRpcForceTcp; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + cfg.option = "statusInterval"; cfg.ptr = &tsStatusInterval; cfg.valType = TAOS_CFG_VTYPE_INT32; diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index 1f2e0fadb3..aac92ee99b 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -399,7 +399,7 @@ void rpcSendRequest(void *shandle, const SRpcEpSet *pEpSet, SRpcMsg *pMsg, int64 pContext->oldInUse = pEpSet->inUse; pContext->connType = RPC_CONN_UDPC; - if (contLen > tsRpcMaxUdpSize) pContext->connType = RPC_CONN_TCPC; + if (contLen > tsRpcMaxUdpSize || tsRpcForceTcp) pContext->connType = RPC_CONN_TCPC; // connection type is application specific. // for TDengine, all the query, show commands shall have TCP connection -- GitLab