From 05d2260d046add6a7fbef394a972ecad1db3b1d8 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 27 Oct 2020 18:12:58 +0800 Subject: [PATCH] [td-225] add tcp transfer threshold --- src/inc/tglobalcfg.h | 2 ++ src/rpc/src/tudp.c | 3 ++- src/util/src/tglobalcfg.c | 6 ++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/inc/tglobalcfg.h b/src/inc/tglobalcfg.h index 462d488a6b..a9fd229714 100644 --- a/src/inc/tglobalcfg.h +++ b/src/inc/tglobalcfg.h @@ -122,6 +122,8 @@ extern int tsBalancePolicy; extern int tsOfflineThreshold; extern int tsMgmtEqualVnodeNum; +extern int tsTCPTransferThreshold; + extern int tsEnableHttpModule; extern int tsEnableMonitorModule; extern int tsRestRowLimit; diff --git a/src/rpc/src/tudp.c b/src/rpc/src/tudp.c index a38871669c..e86b1de36b 100644 --- a/src/rpc/src/tudp.c +++ b/src/rpc/src/tudp.c @@ -756,7 +756,8 @@ int taosSendUdpData(uint32_t ip, uint16_t port, char *data, int dataLen, void *c if (pConn == NULL || pConn->signature != pConn) return -1; - if (dataLen >= RPC_MAX_UDP_SIZE) return taosSendPacketViaTcp(ip, port, data, dataLen, chandle); + assert(tsTCPTransferThreshold <= RPC_MAX_UDP_SIZE && tsTCPTransferThreshold > 0); + if (dataLen >= tsTCPTransferThreshold) return taosSendPacketViaTcp(ip, port, data, dataLen, chandle); if (pConn->hash == NULL) { struct sockaddr_in destAdd; diff --git a/src/util/src/tglobalcfg.c b/src/util/src/tglobalcfg.c index 813c66241a..91b4792f4f 100644 --- a/src/util/src/tglobalcfg.c +++ b/src/util/src/tglobalcfg.c @@ -130,6 +130,8 @@ int tsBalancePolicy = 0; // 1-use sys.montor int tsOfflineThreshold = 864000; // seconds 10days int tsMgmtEqualVnodeNum = 4; +int tsTCPTransferThreshold = 65480; // RPC_MAX_UDP_SIZE + int tsEnableHttpModule = 1; int tsEnableMonitorModule = 1; int tsRestRowLimit = 10240; @@ -710,6 +712,10 @@ static void doInitGlobalConfig() { TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT, 0, 0, tListLen(tsCharset), TSDB_CFG_UTYPE_NONE); + tsInitConfigOption(cfg++, "tcptransferThreshold", &tsTCPTransferThreshold, TSDB_CFG_VTYPE_INT, + TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, + 500, 65480, 0, TSDB_CFG_UTYPE_BYTE); + // connect configs tsInitConfigOption(cfg++, "maxShellConns", &tsMaxShellConns, TSDB_CFG_VTYPE_INT, TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW, -- GitLab