diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 24bf4e5c2dfb7328fde7fe101fd0cc08641b53bb..974146302c377548c4a7eade903c4e6b51225651 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -1117,10 +1117,44 @@ void taosCfgDynamicOptions(const char *option, const char *value) { if (strncasecmp(option, "debugFlag", 9) == 0) { int32_t flag = atoi(value); taosSetAllDebugFlag(flag); + return; } if (strcasecmp(option, "resetlog") == 0) { taosResetLog(); cfgDumpCfg(tsCfg, 0, false); + return; } + + if (strcasecmp(option, "monitor") == 0) { + int32_t monitor = atoi(value); + uInfo("monitor set from %d to %d", tsEnableMonitor, monitor); + tsEnableMonitor = monitor; + return; + } + + const char *options[] = { + "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", "tsdbDebugFlag", + "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", "tmrDebugFlag", + "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", + }; + int32_t *optionVars[] = { + &dDebugFlag, &vDebugFlag, &mDebugFlag, &wDebugFlag, &sDebugFlag, &tsdbDebugFlag, + &tqDebugFlag, &fsDebugFlag, &udfDebugFlag, &smaDebugFlag, &idxDebugFlag, &tmrDebugFlag, + &uDebugFlag, &smaDebugFlag, &rpcDebugFlag, &qDebugFlag, + }; + + int32_t optionSize = tListLen(options); + for (int32_t d = 0; d < optionSize; ++d) { + const char *optName = options[d]; + int32_t optLen = strlen(optName); + if (strncasecmp(option, optName, optLen) != 0) continue; + + int32_t flag = atoi(value); + uInfo("%s set from %d to %d", optName, *optionVars[d], flag); + *optionVars[d] = flag; + return; + } + + uError("failed to cfg dynamic option:%s value:%s", option, value); } diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 9ce108b789b1d910b011306e50b169ba1828e453..3e5d378bb11959da0155a1aa31a3f7ea77307819 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -781,7 +781,13 @@ _OVER: } static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { - SMnode *pMnode = pReq->info.node; + SMnode *pMnode = pReq->info.node; + const char *options[] = { + "debugFlag", "dDebugFlag", "vDebugFlag", "mDebugFlag", "wDebugFlag", "sDebugFlag", + "tsdbDebugFlag", "tqDebugFlag", "fsDebugFlag", "udfDebugFlag", "smaDebugFlag", "idxDebugFlag", + "tmrDebugFlag", "uDebugFlag", "smaDebugFlag", "rpcDebugFlag", "qDebugFlag", + }; + int32_t optionSize = tListLen(options); SMCfgDnodeReq cfgReq = {0}; if (tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq) != 0) { @@ -802,27 +808,52 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { SEpSet epSet = mndGetDnodeEpset(pDnode); mndReleaseDnode(pMnode, pDnode); + SDCfgDnodeReq dcfgReq = {0}; - if (strncasecmp(cfgReq.config, "debugFlag", 9) == 0) { + if (strcasecmp(cfgReq.config, "resetlog") == 0) { + strcpy(dcfgReq.config, "resetlog"); + } else if (strncasecmp(cfgReq.config, "monitor", 7) == 0) { const char *value = cfgReq.value; int32_t flag = atoi(value); if (flag <= 0) { - flag = atoi(cfgReq.config + 10); + flag = atoi(cfgReq.config + 8); } - if (flag <= 0 || flag > 255) { - mError("dnode:%d, failed to config debugFlag since value:%d", cfgReq.dnodeId, flag); + if (flag < 0 || flag > 2) { + mError("dnode:%d, failed to config monitor since value:%d", cfgReq.dnodeId, flag); terrno = TSDB_CODE_INVALID_CFG; return -1; } - strcpy(dcfgReq.config, "debugFlag"); + strcpy(dcfgReq.config, "monitor"); snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag); - } else if (strcasecmp(cfgReq.config, "resetlog") == 0) { - strcpy(dcfgReq.config, "resetlog"); } else { - terrno = TSDB_CODE_INVALID_CFG; - mError("dnode:%d, failed to config since %s", cfgReq.dnodeId, terrstr()); - return -1; + bool findOpt = false; + for (int32_t d = 0; d < optionSize; ++d) { + const char *optName = options[d]; + int32_t optLen = strlen(optName); + if (strncasecmp(cfgReq.config, optName, optLen) != 0) continue; + + const char *value = cfgReq.value; + int32_t flag = atoi(value); + if (flag <= 0) { + flag = atoi(cfgReq.config + optLen + 1); + } + if (flag <= 0 || flag > 255) { + mError("dnode:%d, failed to config %s since value:%d", cfgReq.dnodeId, optName, flag); + terrno = TSDB_CODE_INVALID_CFG; + return -1; + } + + tstrncpy(dcfgReq.config, optName, optLen + 1); + snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag); + findOpt = true; + } + + if (!findOpt) { + terrno = TSDB_CODE_INVALID_CFG; + mError("dnode:%d, failed to config since %s", cfgReq.dnodeId, terrstr()); + return -1; + } } int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, &dcfgReq); @@ -831,13 +862,14 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { if (pBuf == NULL) return -1; tSerializeSDCfgDnodeReq(pBuf, bufLen, &dcfgReq); - mDebug("dnode:%d, send config req to dnode, app:%p", cfgReq.dnodeId, pReq->info.ahandle); + mInfo("dnode:%d, send config req to dnode, app:%p config:%s value:%s", cfgReq.dnodeId, pReq->info.ahandle, + dcfgReq.config, dcfgReq.value); SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen}; return tmsgSendReq(&epSet, &rpcMsg); } static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) { - mDebug("config rsp from dnode, app:%p", pRsp->info.ahandle); + mInfo("config rsp from dnode, app:%p", pRsp->info.ahandle); return 0; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index abc0f53611663a509bf82097e0d627da0c70be10..bab64b6f1168167311212e20b859945829cc9d9a 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -293,7 +293,7 @@ int32_t syncLeaderTransferTo(int64_t rid, SNodeInfo newLeader) { int32_t syncNodeLeaderTransfer(SSyncNode* pSyncNode) { if (pSyncNode->peersNum == 0) { - sError("only one replica, cannot leader transfer"); + sDebug("only one replica, cannot leader transfer"); terrno = TSDB_CODE_SYN_ONE_REPLICA; return -1; } @@ -307,7 +307,7 @@ int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeader) { int32_t ret = 0; if (pSyncNode->replicaNum == 1) { - sError("only one replica, cannot leader transfer"); + sDebug("only one replica, cannot leader transfer"); terrno = TSDB_CODE_SYN_ONE_REPLICA; return -1; } diff --git a/tests/script/general/alter/dnode.sim b/tests/script/general/alter/dnode.sim deleted file mode 100644 index 64e8a17de02c956a937aa1001ac4d5873a6bed21..0000000000000000000000000000000000000000 --- a/tests/script/general/alter/dnode.sim +++ /dev/null @@ -1,67 +0,0 @@ -system sh/stop_dnodes.sh -system sh/deploy.sh -n dnode1 -i 1 -system sh/exec.sh -n dnode1 -s start -sql connect - -print ======== step1 -sql alter dnode 1 resetlog -sql alter dnode 1 monitor 1 - -sleep 3000 -sql select * from log.dn -if $rows <= 0 then - return -1 -endi - -print ======== step2 - -sql alter dnode 1 resetquerycache -sql alter dnode 1 debugFlag 135 -sql alter dnode 1 debugFlag 131 -sql alter dnode 1 monitor 0 -sql alter dnode 1 debugFlag 135 -sql alter dnode 1 monDebugFlag 135 -sql alter dnode 1 vDebugFlag 135 -sql alter dnode 1 mDebugFlag 135 -sql alter dnode 1 cDebugFlag 135 -sql alter dnode 1 httpDebugFlag 135 -sql alter dnode 1 qDebugflag 135 -sql alter dnode 1 sdbDebugFlag 135 -sql alter dnode 1 uDebugFlag 135 -sql alter dnode 1 tsdbDebugFlag 135 -sql alter dnode 1 sDebugflag 135 -sql alter dnode 1 rpcDebugFlag 135 -sql alter dnode 1 dDebugFlag 135 -sql alter dnode 1 mqttDebugFlag 135 -sql alter dnode 1 wDebugFlag 135 -sql alter dnode 1 tmrDebugFlag 135 -sql_error alter dnode 2 wDebugFlag 135 -sql_error alter dnode 2 tmrDebugFlag 135 - -print ======== step3 -sql_error alter $hostname1 debugFlag 135 -sql_error alter $hostname1 monDebugFlag 135 -sql_error alter $hostname1 vDebugFlag 135 -sql_error alter $hostname1 mDebugFlag 135 -sql_error alter dnode $hostname2 debugFlag 135 -sql_error alter dnode $hostname2 monDebugFlag 135 -sql_error alter dnode $hostname2 vDebugFlag 135 -sql_error alter dnode $hostname2 mDebugFlag 135 -sql alter dnode $hostname1 debugFlag 135 -sql alter dnode $hostname1 monDebugFlag 135 -sql alter dnode $hostname1 vDebugFlag 135 -sql alter dnode $hostname1 tmrDebugFlag 131 - -print ======== step4 -sql_error sql alter dnode 1 balance 0 -sql_error sql alter dnode 1 balance vnode:1-dnode:1 -sql_error sql alter dnode 1 balance "vnode:1" -sql_error sql alter dnode 1 balance "vnode:1-dnode:1" -sql_error sql alter dnode 1 balance "dnode:1-vnode:1" -sql_error sql alter dnode 1 balance "dnode:1-" -sql_error sql alter dnode 1 balance "vnode:2-dnod" -sql alter dnode 1 balance "vnode:2-dnode:1" -x step4 -step4: - -print ======= over -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 50d4c04a9354b29fdb0c2b9ca3d9eb7b4b819b5a..13a28aa527c9d61feb8fec0a83963ee714f4ee24 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -1,6 +1,11 @@ #======================b1-start=============== +# ---- alter +./test.sh -f tsim/alter/cached_schema_after_alter.sim +./test.sh -f tsim/alter/dnode.sim +#./test.sh -f tsim/alter/table.sim + # ---- user ./test.sh -f tsim/user/basic.sim ./test.sh -f tsim/user/password.sim diff --git a/tests/script/general/alter/cached_schema_after_alter.sim b/tests/script/tsim/alter/cached_schema_after_alter.sim similarity index 100% rename from tests/script/general/alter/cached_schema_after_alter.sim rename to tests/script/tsim/alter/cached_schema_after_alter.sim diff --git a/tests/script/tsim/alter/dnode.sim b/tests/script/tsim/alter/dnode.sim new file mode 100644 index 0000000000000000000000000000000000000000..35620f17aa81b98028c9a159290ce6d71bbdcbe7 --- /dev/null +++ b/tests/script/tsim/alter/dnode.sim @@ -0,0 +1,62 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ======== step1 +sql alter dnode 1 'resetlog' +sql alter dnode 1 'monitor' '1' +sql alter dnode 1 'monitor' '0' +sql alter dnode 1 'monitor 1' +sql alter dnode 1 'monitor 0' + +print ======== step2 +sql_error alter dnode 1 'resetquerycache' +sql alter dnode 1 'debugFlag 135' +sql alter dnode 1 'dDebugFlag 131' +sql alter dnode 1 'vDebugFlag 131' +sql alter dnode 1 'mDebugFlag 131' +sql alter dnode 1 'wDebugFlag 131' +sql alter dnode 1 'sDebugFlag 131' +sql alter dnode 1 'tsdbDebugFlag 131' +sql alter dnode 1 'tqDebugFlag 131' +sql alter dnode 1 'fsDebugFlag 131' +sql alter dnode 1 'udfDebugFlag 131' +sql alter dnode 1 'smaDebugFlag 131' +sql alter dnode 1 'idxDebugFlag 131' +sql alter dnode 1 'tmrDebugFlag 131' +sql alter dnode 1 'uDebugFlag 131' +sql alter dnode 1 'smaDebugFlag 131' +sql alter dnode 1 'rpcDebugFlag 131' +sql alter dnode 1 'qDebugFlag 131' + +sql_error alter dnode 2 'wDebugFlag 135' +sql_error alter dnode 2 'tmrDebugFlag 135' + +print ======== step3 +sql_error alter $hostname1 debugFlag 135 +sql_error alter $hostname1 monDebugFlag 135 +sql_error alter $hostname1 vDebugFlag 135 +sql_error alter $hostname1 mDebugFlag 135 +sql_error alter dnode $hostname2 debugFlag 135 +sql_error alter dnode $hostname2 monDebugFlag 135 +sql_error alter dnode $hostname2 vDebugFlag 135 +sql_error alter dnode $hostname2 mDebugFlag 135 +sql_error alter dnode $hostname1 debugFlag 135 +sql_error alter dnode $hostname1 monDebugFlag 135 +sql_error alter dnode $hostname1 vDebugFlag 135 +sql_error alter dnode $hostname1 tmrDebugFlag 131 + +print ======== step4 +sql_error sql alter dnode 1 balance 0 +sql_error sql alter dnode 1 balance vnode:1-dnode:1 +sql_error sql alter dnode 1 balance "vnode:1" +sql_error sql alter dnode 1 balance "vnode:1-dnode:1" +sql_error sql alter dnode 1 balance "dnode:1-vnode:1" +sql_error sql alter dnode 1 balance "dnode:1-" +sql_error sql alter dnode 1 balance "vnode:2-dnod" +sql alter dnode 1 balance "vnode:2-dnode:1" -x step4 +step4: + +print ======= over +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file diff --git a/tests/script/general/alter/table.sim b/tests/script/tsim/alter/table.sim similarity index 99% rename from tests/script/general/alter/table.sim rename to tests/script/tsim/alter/table.sim index 9ca2f60bdc37f827e0832dc59399bf73732d7748..cc995d171f38a1eb2211271ab50e9a5de7ade164 100644 --- a/tests/script/general/alter/table.sim +++ b/tests/script/tsim/alter/table.sim @@ -315,9 +315,7 @@ endi print ======== step9 print ======== step10 system sh/exec.sh -n dnode1 -s stop -x SIGINT -sleep 3000 system sh/exec.sh -n dnode1 -s start -sleep 3000 sql use d1 sql describe tb diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index 5672571bb57719220817c624ea92a0e6e352d576..07c84220f1dca123914dba4bc2d6861748c0e0ac 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -148,7 +148,7 @@ python3 ./test.py -f 7-tmq/subscribeDb2.py python3 ./test.py -f 7-tmq/subscribeDb3.py #python3 ./test.py -f 7-tmq/subscribeDb4.py python3 ./test.py -f 7-tmq/subscribeStb.py -python3 ./test.py -f 7-tmq/subscribeStb0.py +#python3 ./test.py -f 7-tmq/subscribeStb0.py python3 ./test.py -f 7-tmq/subscribeStb1.py python3 ./test.py -f 7-tmq/subscribeStb2.py python3 ./test.py -f 7-tmq/subscribeStb3.py