diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 8bce28d34c518c822c3df150f329e043eb1b0274..2fc1765b415851f09ab2cffd45e022ef846c5e6e 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -55,23 +55,8 @@ extern float tsStreamComputDelayRatio; // the delayed computing ration of the extern int32_t tsProjectExecInterval; extern int64_t tsMaxRetentWindow; -// system info - -extern uint32_t tsVersion; - - -// lossy -extern char tsLossyColumns[]; -extern double tsFPrecision; -extern double tsDPrecision; -extern uint32_t tsMaxRange; -extern uint32_t tsCurRange; -extern char tsCompressor[]; - - #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize) -void taosInitGlobalCfg(); int32_t taosCfgDynamicOptions(char *msg); bool taosCheckBalanceCfgOptions(const char *option, int32_t *vnodeId, int32_t *dnodeId); void taosAddDataDir(int index, char *v1, int level, int primary); diff --git a/include/dnode/mgmt/dnode.h b/include/dnode/mgmt/dnode.h index 99fe2457a80da8318cc933d09aaa3d52cb9296bf..5d6c869b4d8a66463590fa0762da3658adc2a41e 100644 --- a/include/dnode/mgmt/dnode.h +++ b/include/dnode/mgmt/dnode.h @@ -32,6 +32,8 @@ typedef struct { uint16_t numOfCommitThreads; bool enableTelem; bool printAuth; + int32_t rpcTimer; + int32_t rpcMaxTime; char timezone[TSDB_TIMEZONE_LEN]; char locale[TSDB_LOCALE_LEN]; char charset[TSDB_LOCALE_LEN]; diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index 538aeb1a0e7927469cf90721dbbc16140c181e93..60e23f132cfe5c056c9863af1a007a2250c3f50d 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -81,9 +81,15 @@ typedef struct SRpcInit { void *parent; } SRpcInit; -int32_t rpcInit(); +typedef struct { + int32_t rpcTimer; + int32_t rpcMaxTime; + int32_t sver; +} SRpcCfg; + +int32_t rpcInit(SRpcCfg *pCfg); void rpcCleanup(); -void * rpcOpen(const SRpcInit *pRpc); +void *rpcOpen(const SRpcInit *pRpc); void rpcClose(void *); void * rpcMallocCont(int contLen); void rpcFreeCont(void *pCont); diff --git a/source/client/src/clientCfg.c b/source/client/src/clientCfg.c index 22b1407a15691a9424ca1e769c563586762513ac..826626fd778361f3f5660c1c9680d04837ff5a26 100644 --- a/source/client/src/clientCfg.c +++ b/source/client/src/clientCfg.c @@ -17,7 +17,7 @@ #include "clientInt.h" #include "ulog.h" -// todo refact +// todo refact SConfig *tscCfg; static int32_t tscLoadCfg(SConfig *pConfig, const char *inputCfgDir, const char *envFile, const char *apolloUrl) { @@ -125,7 +125,7 @@ static int32_t tscAddEpCfg(SConfig *pCfg) { return -1; } if (cfgAddString(pCfg, "fqdn", defaultFqdn) != 0) return -1; - + int32_t defaultServerPort = 6030; if (cfgAddInt32(pCfg, "serverPort", defaultServerPort, 1, 65056) != 0) return -1; @@ -142,11 +142,10 @@ static int32_t tscAddEpCfg(SConfig *pCfg) { static int32_t tscAddCfg(SConfig *pCfg) { if (tscAddEpCfg(pCfg) != 0) return -1; - // if (cfgAddString(pCfg, "buildinfo", buildinfo) != 0) return -1; // if (cfgAddString(pCfg, "gitinfo", gitinfo) != 0) return -1; // if (cfgAddString(pCfg, "version", version) != 0) return -1; - + // if (cfgAddDir(pCfg, "dataDir", tsDataDir) != 0) return -1; if (cfgAddTimezone(pCfg, "timezone", "") != 0) return -1; if (cfgAddLocale(pCfg, "locale", "") != 0) return -1; @@ -160,7 +159,8 @@ static int32_t tscAddCfg(SConfig *pCfg) { if (cfgAddFloat(pCfg, "numOfThreadsPerCore", 1, 0, 10) != 0) return -1; if (cfgAddFloat(pCfg, "ratioOfQueryCores", 1, 0, 5) != 0) return -1; if (cfgAddInt32(pCfg, "shellActivityTimer", 3, 1, 120) != 0) return -1; - + if (cfgAddInt32(pCfg, "rpcTimer", 300, 100, 3000) != 0) return -1; + if (cfgAddInt32(pCfg, "rpcMaxTime", 600, 100, 7200) != 0) return -1; if (cfgAddInt32(pCfg, "maxConnections", 50000, 1, 100000) != 0) return -1; return 0; } @@ -169,8 +169,6 @@ int32_t tscCheckCfg(SConfig *pCfg) { bool enableCore = cfgGetItem(pCfg, "enableCoreFile")->bval; taosSetCoreDump(enableCore); - - return 0; } diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 38f94ecae879ae46db9c3aabd21fe7a302b79c2d..c982b2404692cba1387a93424c2ade2d64ded607 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -223,7 +223,11 @@ void taos_init_imp(void) { initMsgHandleFp(); initQueryModuleMsgHandle(); - rpcInit(); + SRpcCfg rpcCfg = {0}; + rpcCfg.rpcTimer = cfgGetItem(tscCfg, "rpcTimer")->i32; + rpcCfg.rpcMaxTime = cfgGetItem(tscCfg, "rpcMaxTime")->i32; + rpcCfg.sver = 30000000; + rpcInit(&rpcCfg); SCatalogCfg cfg = {.maxDBCacheNum = 100, .maxTblCacheNum = 100}; catalogInit(&cfg); diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 5414f17a6247769ba38c84d0dac8c37d8e25168e..ac36179a264ad8a23c6f7431279b36abe5b68458 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -49,7 +49,7 @@ int main(int argc, char** argv) { } TEST(testCase, driverInit_Test) { - taosInitGlobalCfg(); + // taosInitGlobalCfg(); // taos_init(); } diff --git a/source/client/test/tmqTest.cpp b/source/client/test/tmqTest.cpp index 9f8ff7143a822cfe3abb69b1475f884397501436..c34c10d8714fa443bb161333ab622093ec6eebd7 100644 --- a/source/client/test/tmqTest.cpp +++ b/source/client/test/tmqTest.cpp @@ -34,7 +34,7 @@ int main(int argc, char** argv) { } TEST(testCase, driverInit_Test) { - taosInitGlobalCfg(); + // taosInitGlobalCfg(); // taos_init(); } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 72783bf4ab5d6f0fd9597bb6b4641bb9f8c153ab..be98a0e2404b01a4bb2654ba557abd7a4ab7ba3e 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -118,23 +118,6 @@ bool tsdbForceKeepFile = false; */ int64_t tsTickPerDay[] = {86400000L, 86400000000L, 86400000000000L}; -// system info -int32_t tsTotalMemoryMB = 0; -uint32_t tsVersion = 0; - -// -// lossy compress 6 -// -char tsLossyColumns[32] = ""; // "float|double" means all float and double columns can be lossy compressed. set empty - // can close lossy compress. -// below option can take effect when tsLossyColumns not empty -double tsFPrecision = 1E-8; // float column precision -double tsDPrecision = 1E-16; // double column precision -uint32_t tsMaxRange = 500; // max range -uint32_t tsCurRange = 100; // range -char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPRESSOR - - int32_t (*monStartSystemFp)() = NULL; void (*monStopSystemFp)() = NULL; void (*monExecuteSQLFp)(char *sql) = NULL; @@ -529,8 +512,6 @@ static void doInitGlobalConfig(void) { #endif } -void taosInitGlobalCfg() { pthread_once(&tsInitGlobalCfgOnce, doInitGlobalConfig); } - /* * alter dnode 1 balance "vnode:1-dnode:2" */ diff --git a/source/dnode/mgmt/daemon/src/dmnCfg.c b/source/dnode/mgmt/daemon/src/dmnCfg.c index 7bf538caed1ee09e2539a44d6101a47f85adea3e..52aa22a53323a944b2074d44000c7f164c8c4b15 100644 --- a/source/dnode/mgmt/daemon/src/dmnCfg.c +++ b/source/dnode/mgmt/daemon/src/dmnCfg.c @@ -80,6 +80,9 @@ static int32_t dmnAddDnodeCfg(SConfig *pCfg) { if (cfgAddFloat(pCfg, "ratioOfQueryCores", 1, 0, 5) != 0) return -1; if (cfgAddInt32(pCfg, "maxShellConns", 50000, 10, 50000000) != 0) return -1; if (cfgAddInt32(pCfg, "shellActivityTimer", 3, 1, 120) != 0) return -1; + if (cfgAddInt32(pCfg, "rpcTimer", 300, 100, 3000) != 0) return -1; + if (cfgAddInt32(pCfg, "rpcMaxTime", 600, 100, 7200) != 0) return -1; + return 0; } @@ -184,6 +187,8 @@ SDnodeEnvCfg dmnGetEnvCfg(SConfig *pCfg) { envCfg.numOfCores = cfgGetItem(pCfg, "numOfCores")->i32; envCfg.numOfCommitThreads = (uint16_t)cfgGetItem(pCfg, "numOfCommitThreads")->i32; envCfg.enableTelem = cfgGetItem(pCfg, "telemetryReporting")->bval; + envCfg.rpcMaxTime = cfgGetItem(pCfg, "rpcMaxTime")->i32; + envCfg.rpcTimer = cfgGetItem(pCfg, "rpcTimer")->i32; return envCfg; } diff --git a/source/dnode/mgmt/impl/src/dndEnv.c b/source/dnode/mgmt/impl/src/dndEnv.c index 58517c8151cdacc9f6c2655ce897aadb7fc1a31d..b8f249f838203b57232c315a3503729fe2b13449 100644 --- a/source/dnode/mgmt/impl/src/dndEnv.c +++ b/source/dnode/mgmt/impl/src/dndEnv.c @@ -270,7 +270,8 @@ int32_t dndInit(const SDnodeEnvCfg *pCfg) { taosBlockSIGPIPE(); taosResolveCRC(); - if (rpcInit() != 0) { + SRpcCfg rpcCfg = {.rpcTimer = pCfg->rpcTimer, .rpcMaxTime = pCfg->rpcMaxTime, .sver = pCfg->sver}; + if (rpcInit(&rpcCfg) != 0) { dError("failed to init rpc since %s", terrstr()); dndCleanup(); return -1; diff --git a/source/dnode/mgmt/impl/test/sut/src/sut.cpp b/source/dnode/mgmt/impl/test/sut/src/sut.cpp index d32bdf29c600e887f38bfba40ec69c2c0992e7b5..9863fd9f54e7879df574c1e343387a35e9a0184f 100644 --- a/source/dnode/mgmt/impl/test/sut/src/sut.cpp +++ b/source/dnode/mgmt/impl/test/sut/src/sut.cpp @@ -43,6 +43,8 @@ void Testbase::Init(const char* path, int16_t port) { SDnodeEnvCfg cfg = {0}; cfg.numOfCommitThreads = 1; cfg.numOfCores = 1; + cfg.rpcMaxTime = 600; + cfg.rpcTimer = 300; dndInit(&cfg); char fqdn[] = "localhost"; diff --git a/source/libs/transport/src/rpcMain.c b/source/libs/transport/src/rpcMain.c index 44bb6fdb702a349eda00acf2e503d58e98324965..cfd01bf3be7c4b0256dde3a3669b88dbaf69fb40 100644 --- a/source/libs/transport/src/rpcMain.c +++ b/source/libs/transport/src/rpcMain.c @@ -146,8 +146,9 @@ typedef struct SRpcConn { static int tsRpcRefId = -1; static int32_t tsRpcNum = 0; -int32_t tsRpcTimer = 300; -int32_t tsRpcMaxTime = 600; // seconds; +int32_t tsRpcTimer = 300; +int32_t tsRpcMaxTime = 600; // seconds; +uint32_t tsVersion = 0; // static pthread_once_t tsRpcInit = PTHREAD_ONCE_INIT; @@ -228,7 +229,9 @@ static void rpcInitImp(void) { tsFqdnHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); } -int32_t rpcInit(void) { +int32_t rpcInit(SRpcCfg *pCfg) { + tsRpcTimer = pCfg->rpcTimer; + tsRpcMaxTime = pCfg->rpcMaxTime; pthread_once(&tsRpcInitOnce, rpcInitImp); return 0; } diff --git a/source/os/src/osEnv.c b/source/os/src/osEnv.c index b90d9fbe94fdaf75aa363c25b5a876e6579877e1..7417c6ff8443af4a2da8ebb8bd1c339f72323ed7 100644 --- a/source/os/src/osEnv.c +++ b/source/os/src/osEnv.c @@ -82,6 +82,8 @@ char tsDataDir[PATH_MAX] = "/var/lib/taos"; char tsLogDir[PATH_MAX] = "/var/log/taos"; char tsTempDir[PATH_MAX] = "/tmp/"; -void osInit() {} +void osInit() { + srand(taosSafeRand()); +} #endif