From 7334f5196e216a47f7ead8adfaebb570ddf907db Mon Sep 17 00:00:00 2001 From: root Date: Fri, 11 Sep 2020 10:50:17 +0800 Subject: [PATCH] TD-1382 --- src/dnode/src/dnodeModule.c | 8 +++++--- src/inc/dnode.h | 2 +- src/mnode/src/mnodeSdb.c | 5 +++-- .../script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim | 3 ++- .../unique/arbitrator/replica_changeWithArbitrator.sim | 1 + tests/script/unique/dnode/alternativeRole.sim | 5 +++-- 6 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/dnode/src/dnodeModule.c b/src/dnode/src/dnodeModule.c index bcbc98b5b3..0a5b9b550c 100644 --- a/src/dnode/src/dnodeModule.c +++ b/src/dnode/src/dnodeModule.c @@ -146,8 +146,8 @@ void dnodeProcessModuleStatus(uint32_t moduleStatus) { } } -void dnodeCheckModules() { - if (tsModuleStatus & TSDB_MOD_MNODE) return; +bool dnodeCheckMnodeStarting() { + if (tsModuleStatus & TSDB_MOD_MNODE) return false; SDMMnodeInfos *mnodes = dnodeGetMnodeInfos(); for (int32_t i = 0; i < mnodes->nodeNum; ++i) { @@ -156,7 +156,9 @@ void dnodeCheckModules() { uint32_t moduleStatus = tsModuleStatus | (1 << TSDB_MOD_MNODE);; dInfo("start mnode module, module status:%d, new status:%d", tsModuleStatus, moduleStatus); dnodeProcessModuleStatus(moduleStatus); - break; + return true; } } + + return false; } diff --git a/src/inc/dnode.h b/src/inc/dnode.h index 028041b2d2..fda9c1c1dd 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -43,7 +43,7 @@ void dnodeGetMnodeEpSetForPeer(void *epSet); void dnodeGetMnodeEpSetForShell(void *epSet); void * dnodeGetMnodeInfos(); int32_t dnodeGetDnodeId(); -void dnodeCheckModules(); +bool dnodeCheckMnodeStarting(); void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)); void dnodeSendMsgToDnode(SRpcEpSet *epSet, SRpcMsg *rpcMsg); diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index 3ff5cc4828..60f1e8e80b 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -298,8 +298,9 @@ static void sdbUpdateSyncTmrFp(void *param, void *tmrId) { sdbUpdateSync(); } void sdbUpdateSync() { if (!mnodeIsRunning()) { mDebug("mnode not start yet, update sync info later"); - dnodeCheckModules(); - taosTmrReset(sdbUpdateSyncTmrFp, 1000, NULL, tsMnodeTmr, &tsUpdateSyncTmr); + if (dnodeCheckMnodeStarting()) { + taosTmrReset(sdbUpdateSyncTmrFp, 1000, NULL, tsMnodeTmr, &tsUpdateSyncTmr); + } return; } mDebug("update sync info in sdb"); diff --git a/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim b/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim index b625619678..aaf0da8553 100644 --- a/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim +++ b/tests/script/unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim @@ -53,7 +53,7 @@ system sh/exec.sh -n dnode2 -s start system sh/exec.sh -n dnode3 -s start sql create dnode $hostname2 sql create dnode $hostname3 -sleep 3000 +sleep 5000 $sleepTimer = 3000 @@ -225,6 +225,7 @@ if $data00 != $totalRows then endi print ============== step5: stop dnode2, and remove its vnode +sleep 5000 system sh/exec.sh -n dnode2 -s stop -x SIGINT sleep $sleepTimer diff --git a/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim index 10964b9209..3715be5fa9 100644 --- a/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim +++ b/tests/script/unique/arbitrator/replica_changeWithArbitrator.sim @@ -193,6 +193,7 @@ if $data00 != $totalRows then endi print ============== step5: stop dnode1 +sleep 5000 system sh/exec.sh -n dnode1 -s stop sleep 3000 diff --git a/tests/script/unique/dnode/alternativeRole.sim b/tests/script/unique/dnode/alternativeRole.sim index ab37c1603a..b5d861c44f 100644 --- a/tests/script/unique/dnode/alternativeRole.sim +++ b/tests/script/unique/dnode/alternativeRole.sim @@ -18,13 +18,14 @@ system sh/cfg.sh -n dnode3 -c numOfMnodes -v 3 print ========== step1 system sh/exec.sh -n dnode1 -s start +sleep 3000 sql connect + sql create dnode $hostname2 system sh/exec.sh -n dnode2 -s start -sleep 3000 sql create dnode $hostname3 system sh/exec.sh -n dnode3 -s start -sleep 3000 +sleep 5000 sql show dnodes print dnode1 $data5_1 -- GitLab